Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ name: Tiny URL CI Pipeline
on:
push:
branches:
- main
- 'feature/**' # Trigger workflow for feature branches
- 'feat/**' # Trigger workflow for feature branches
- 'doc/**' # Trigger workflow for feature branches
- 'chore/**' # Trigger workflow for feature branches
- 'fix/**' # Trigger workflow for feature branches
- '**'
pull_request:
branches:
- main
Expand All @@ -18,6 +13,9 @@ jobs:
api:
name: API Build & Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: api

steps:
- name: Checkout Repository
Expand All @@ -28,7 +26,7 @@ jobs:
with:
node-version: 18
cache: yarn
cache-dependency-path: api/yarn-lock.json # Specify the path to your yarn.lock
cache-dependency-path: api/yarn.lock # Specify the path to your yarn.lock

- name: Install Dependencies (API)
working-directory: api
Expand All @@ -37,14 +35,24 @@ jobs:
#- name: Lint API
# run: npm run lint

- name: Create .env file
run: |
echo "MACHINE_ID=1" > .env
working-directory: api # Ensure it is created inside `api/`

- name: Run Tests (API)
run: yarn test

- name: Build API
run: yarn build

# Webapp (Next.js) Build & Test
webapp:
name: Webapp Build & Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: webapp

steps:
- name: Checkout Repository
Expand All @@ -55,7 +63,7 @@ jobs:
with:
node-version: 18
cache: yarn
cache-dependency-path: webapp/yarn-lock.json
cache-dependency-path: webapp/yarn.lock # Specify the path to your yarn.lock

- name: Install Dependencies (Webapp)
run: yarn install --frozen-lockfile
Expand All @@ -64,15 +72,15 @@ jobs:
run: yarn lint

#- name: Run Tests (Webapp)
# run: npm test
# run: npm test

- name: Build Webapp
run: yarn build

# Merge Blocker: Ensure Both Builds Pass
merge_guard:
name: Ensure All Jobs Passed
needs: [api, webapp]
needs: [ api, webapp ]
runs-on: ubuntu-latest
steps:
- name: Check for Failures
Expand Down
52 changes: 26 additions & 26 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,35 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^4.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
"@nestjs/common": "10.0.0",
"@nestjs/config": "4.0.0",
"@nestjs/core": "10.0.0",
"@nestjs/platform-express": "10.0.0",
"reflect-metadata": "0.2.0",
"rxjs": "7.8.1"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0",
"@types/express": "^5.0.0",
"@types/jest": "^29.5.2",
"@types/node": "^20.3.1",
"@types/supertest": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"eslint": "^8.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"prettier": "^3.0.0",
"source-map-support": "^0.5.21",
"supertest": "^7.0.0",
"ts-jest": "^29.1.0",
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
"@nestjs/schematics": "10.0.0",
"@nestjs/testing": "10.0.0",
"@types/express": "5.0.0",
"@types/jest": "29.5.2",
"@types/node": "20.3.1",
"@types/supertest": "6.0.0",
"@typescript-eslint/eslint-plugin": "8.0.0",
"@typescript-eslint/parser": "8.0.0",
"eslint": "8.0.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-prettier": "5.0.0",
"jest": "29.5.0",
"prettier": "3.0.0",
"source-map-support": "0.5.21",
"supertest": "7.0.0",
"ts-jest": "29.1.0",
"ts-loader": "9.4.3",
"ts-node": "10.9.1",
"tsconfig-paths": "4.2.0",
"typescript": "5.1.3"
},
"jest": {
"moduleFileExtensions": [
Expand Down
4 changes: 4 additions & 0 deletions api/src/shorten-url/shorten-url.id-generator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export class ShortenUrlIdGeneratorService {
private lastTimestamp: number;

constructor(private readonly configService: ConfigService) {
// check if the machine id is not null
if (!this.configService.get<number>('MACHINE_ID'))
throw new Error('MACHINE_ID is not defined in the environment variables');

this.machineId = Number(this.configService.get<number>('MACHINE_ID'));
if (
this.machineId < 0 ||
Expand Down
Loading
Loading