diff --git a/apps/backend-v2/package.json b/apps/backend-v2/package.json index 73050d67..9a606340 100644 --- a/apps/backend-v2/package.json +++ b/apps/backend-v2/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "npx tsc", "start": "node build/src/server.js", - "dev": "nodemon src/server.ts", + "dev": "nodemon src/server.ts", "typecheck": "tsc --pretty" }, "dependencies": { diff --git a/backend-nest/.eslintrc.js b/backend-nest/.eslintrc.js index 259de13c..791ca93b 100644 --- a/backend-nest/.eslintrc.js +++ b/backend-nest/.eslintrc.js @@ -1,25 +1,25 @@ module.exports = { - parser: '@typescript-eslint/parser', - parserOptions: { - project: 'tsconfig.json', - tsconfigRootDir: __dirname, - sourceType: 'module', - }, - plugins: ['@typescript-eslint/eslint-plugin'], - extends: [ - 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', - ], - root: true, - env: { - node: true, - jest: true, - }, - ignorePatterns: ['.eslintrc.js'], - rules: { - '@typescript-eslint/interface-name-prefix': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - }, + parser: "@typescript-eslint/parser", + parserOptions: { + project: "tsconfig.json", + tsconfigRootDir: __dirname, + sourceType: "module", + }, + plugins: ["@typescript-eslint/eslint-plugin"], + extends: [ + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended", + ], + root: true, + env: { + node: true, + jest: true, + }, + ignorePatterns: [".eslintrc.js"], + rules: { + "@typescript-eslint/interface-name-prefix": "off", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/explicit-module-boundary-types": "off", + "@typescript-eslint/no-explicit-any": "off", + }, }; diff --git a/backend-nest/README.md b/backend-nest/README.md index f5aa86c5..f3fc94cf 100644 --- a/backend-nest/README.md +++ b/backend-nest/README.md @@ -64,9 +64,9 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors ## Stay in touch -- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com) -- Website - [https://nestjs.com](https://nestjs.com/) -- Twitter - [@nestframework](https://twitter.com/nestframework) +- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com) +- Website - [https://nestjs.com](https://nestjs.com/) +- Twitter - [@nestframework](https://twitter.com/nestframework) ## License diff --git a/backend-nest/nest-cli.json b/backend-nest/nest-cli.json index f9aa683b..363961e6 100644 --- a/backend-nest/nest-cli.json +++ b/backend-nest/nest-cli.json @@ -1,8 +1,8 @@ { - "$schema": "https://json.schemastore.org/nest-cli", - "collection": "@nestjs/schematics", - "sourceRoot": "src", - "compilerOptions": { - "deleteOutDir": true - } + "$schema": "https://json.schemastore.org/nest-cli", + "collection": "@nestjs/schematics", + "sourceRoot": "src", + "compilerOptions": { + "deleteOutDir": true + } } diff --git a/backend-nest/package.json b/backend-nest/package.json index 633c8dae..ed7ee325 100644 --- a/backend-nest/package.json +++ b/backend-nest/package.json @@ -1,67 +1,67 @@ { - "name": "@metro-now/backend-nest", - "version": "0.0.1", - "scripts": { - "build": "nest build", - "start": "nest start", - "start:dev": "nest start --watch", - "start:debug": "nest start --debug --watch", - "start:prod": "node dist/main", - "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", - "test": "jest", - "test:watch": "jest --watch", - "test:cov": "jest --coverage", - "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --config ./test/jest-e2e.json" - }, - "dependencies": { - "@nestjs/common": "^10.0.0", - "@nestjs/config": "^3.2.2", - "@nestjs/core": "^10.0.0", - "@nestjs/platform-express": "^10.0.0", - "radash": "^12.1.0", - "reflect-metadata": "^0.2.0", - "rxjs": "^7.8.1", - "zod": "^3.23.8" - }, - "devDependencies": { - "@nestjs/cli": "^10.0.0", - "@nestjs/schematics": "^10.0.0", - "@nestjs/testing": "^10.0.0", - "@types/express": "^4.17.17", - "@types/jest": "^29.5.2", - "@types/node": "^20.3.1", - "@types/supertest": "^6.0.0", - "@typescript-eslint/eslint-plugin": "^6.0.0", - "@typescript-eslint/parser": "^6.0.0", - "eslint": "^8.42.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": "^6.3.3", - "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": [ - "js", - "json", - "ts" - ], - "rootDir": "src", - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" + "name": "@metro-now/backend-nest", + "version": "0.0.1", + "scripts": { + "build": "nest build", + "start": "nest start", + "start:dev": "nest start --watch", + "start:debug": "nest start --debug --watch", + "start:prod": "node dist/main", + "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", + "test": "jest", + "test:watch": "jest --watch", + "test:cov": "jest --coverage", + "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", + "test:e2e": "jest --config ./test/jest-e2e.json" }, - "collectCoverageFrom": [ - "**/*.(t|j)s" - ], - "coverageDirectory": "../coverage", - "testEnvironment": "node" - } + "dependencies": { + "@nestjs/common": "^10.0.0", + "@nestjs/config": "^3.2.2", + "@nestjs/core": "^10.0.0", + "@nestjs/platform-express": "^10.0.0", + "radash": "^12.1.0", + "reflect-metadata": "^0.2.0", + "rxjs": "^7.8.1", + "zod": "^3.23.8" + }, + "devDependencies": { + "@nestjs/cli": "^10.0.0", + "@nestjs/schematics": "^10.0.0", + "@nestjs/testing": "^10.0.0", + "@types/express": "^4.17.17", + "@types/jest": "^29.5.2", + "@types/node": "^20.3.1", + "@types/supertest": "^6.0.0", + "@typescript-eslint/eslint-plugin": "^6.0.0", + "@typescript-eslint/parser": "^6.0.0", + "eslint": "^8.42.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": "^6.3.3", + "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": [ + "js", + "json", + "ts" + ], + "rootDir": "src", + "testRegex": ".*\\.spec\\.ts$", + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + }, + "collectCoverageFrom": [ + "**/*.(t|j)s" + ], + "coverageDirectory": "../coverage", + "testEnvironment": "node" + } } diff --git a/backend-nest/src/app.controller.spec.ts b/backend-nest/src/app.controller.spec.ts index d22f3890..d9d81e1b 100644 --- a/backend-nest/src/app.controller.spec.ts +++ b/backend-nest/src/app.controller.spec.ts @@ -1,22 +1,22 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; +import { Test, TestingModule } from "@nestjs/testing"; +import { AppController } from "./app.controller"; +import { AppService } from "./app.service"; -describe('AppController', () => { - let appController: AppController; +describe("AppController", () => { + let appController: AppController; - beforeEach(async () => { - const app: TestingModule = await Test.createTestingModule({ - controllers: [AppController], - providers: [AppService], - }).compile(); + beforeEach(async () => { + const app: TestingModule = await Test.createTestingModule({ + controllers: [AppController], + providers: [AppService], + }).compile(); - appController = app.get(AppController); - }); + appController = app.get(AppController); + }); - describe('root', () => { - it('should return "Hello World!"', () => { - expect(appController.getHello()).toBe('Hello World!'); + describe("root", () => { + it('should return "Hello World!"', () => { + expect(appController.getHello()).toBe("Hello World!"); + }); }); - }); }); diff --git a/backend-nest/src/app.controller.ts b/backend-nest/src/app.controller.ts index cce879ee..00e6336b 100644 --- a/backend-nest/src/app.controller.ts +++ b/backend-nest/src/app.controller.ts @@ -1,12 +1,12 @@ -import { Controller, Get } from '@nestjs/common'; -import { AppService } from './app.service'; +import { Controller, Get } from "@nestjs/common"; +import { AppService } from "./app.service"; @Controller() export class AppController { - constructor(private readonly appService: AppService) {} + constructor(private readonly appService: AppService) {} - @Get() - getHello(): string { - return this.appService.getHello(); - } + @Get() + getHello(): string { + return this.appService.getHello(); + } } diff --git a/backend-nest/src/app.module.ts b/backend-nest/src/app.module.ts index 4ef17f6a..f857c25b 100644 --- a/backend-nest/src/app.module.ts +++ b/backend-nest/src/app.module.ts @@ -1,11 +1,11 @@ -import { Module } from '@nestjs/common'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; -import { MetroController } from './metro/metro.controller'; -import { ConfigModule } from '@nestjs/config'; +import { Module } from "@nestjs/common"; +import { AppController } from "./app.controller"; +import { AppService } from "./app.service"; +import { MetroController } from "./metro/metro.controller"; +import { ConfigModule } from "@nestjs/config"; @Module({ - imports: [ConfigModule.forRoot()], - controllers: [AppController, MetroController], - providers: [AppService], + imports: [ConfigModule.forRoot()], + controllers: [AppController, MetroController], + providers: [AppService], }) export class AppModule {} diff --git a/backend-nest/src/app.service.ts b/backend-nest/src/app.service.ts index 927d7cca..07de6b45 100644 --- a/backend-nest/src/app.service.ts +++ b/backend-nest/src/app.service.ts @@ -1,8 +1,8 @@ -import { Injectable } from '@nestjs/common'; +import { Injectable } from "@nestjs/common"; @Injectable() export class AppService { - getHello(): string { - return 'Hello World!'; - } + getHello(): string { + return "Hello World!"; + } } diff --git a/backend-nest/src/data/metro-stations.ts b/backend-nest/src/data/metro-stations.ts index 09ca5faf..7a21faad 100644 --- a/backend-nest/src/data/metro-stations.ts +++ b/backend-nest/src/data/metro-stations.ts @@ -1,126 +1,126 @@ -import type { PlatformID } from './platforms'; +import type { PlatformID } from "./platforms"; export const titleByMetroStation = { - andel: 'Anděl', - borislavka: 'Bořislavka', - budejovicka: 'Budějovická', - 'cerny-most': 'Černý Most', - ceskomoravska: 'Českomoravská', - dejvicka: 'Dejvická', - 'depo-hostivar': 'Depo Hostivař', - flora: 'Flora', - florenc: 'Florenc', - haje: 'Háje', - 'hlavni-nadrazi': 'Hlavní nádraží', - hloubetin: 'Hloubětín', - hradcanska: 'Hradčanská', - hurka: 'Hůrka', - chodov: 'Chodov', - 'i-p-pavlova': 'I. P. Pavlova', - invalidovna: 'Invalidovna', - jinonice: 'Jinonice', - 'jiriho-z-podebrad': 'Jiřího z Poděbrad', - kacerov: 'Kačerov', - 'karlovo-namesti': 'Karlovo náměstí', - kobylisy: 'Kobylisy', - kolbenova: 'Kolbenova', - krizikova: 'Křižíkova', - ladvi: 'Ládví', - letnany: 'Letňany', - luka: 'Luka', - luziny: 'Lužiny', - malostranska: 'Malostranská', - mustek: 'Můstek', - muzeum: 'Muzeum', - 'nadrazi-holesovice': 'Nádraží Holešovice', - 'nadrazi-veleslavin': 'Nádraží Veleslavín', - 'namesti-miru': 'Náměstí Míru', - 'namesti-republiky': 'Náměstí Republiky', - 'narodni-trida': 'Národní třída', - 'nemocnice-motol': 'Nemocnice Motol', - 'nove-butovice': 'Nové Butovice', - opatov: 'Opatov', - palmovka: 'Palmovka', - pankrac: 'Pankrác', - petriny: 'Petřiny', - 'prazskeho-povstani': 'Pražského povstání', - prosek: 'Prosek', - radlicka: 'Radlická', - 'rajska-zahrada': 'Rajská zahrada', - roztyly: 'Roztyly', - skalka: 'Skalka', - 'smichovske-nadrazi': 'Smíchovské nádraží', - staromestska: 'Staroměstská', - stodulky: 'Stodůlky', - strasnicka: 'Strašnická', - strizkov: 'Střížkov', - vltavska: 'Vltavská', - vysocanska: 'Vysočanská', - vysehrad: 'Vyšehrad', - zlicin: 'Zličín', - zelivskeho: 'Želivského', + andel: "Anděl", + borislavka: "Bořislavka", + budejovicka: "Budějovická", + "cerny-most": "Černý Most", + ceskomoravska: "Českomoravská", + dejvicka: "Dejvická", + "depo-hostivar": "Depo Hostivař", + flora: "Flora", + florenc: "Florenc", + haje: "Háje", + "hlavni-nadrazi": "Hlavní nádraží", + hloubetin: "Hloubětín", + hradcanska: "Hradčanská", + hurka: "Hůrka", + chodov: "Chodov", + "i-p-pavlova": "I. P. Pavlova", + invalidovna: "Invalidovna", + jinonice: "Jinonice", + "jiriho-z-podebrad": "Jiřího z Poděbrad", + kacerov: "Kačerov", + "karlovo-namesti": "Karlovo náměstí", + kobylisy: "Kobylisy", + kolbenova: "Kolbenova", + krizikova: "Křižíkova", + ladvi: "Ládví", + letnany: "Letňany", + luka: "Luka", + luziny: "Lužiny", + malostranska: "Malostranská", + mustek: "Můstek", + muzeum: "Muzeum", + "nadrazi-holesovice": "Nádraží Holešovice", + "nadrazi-veleslavin": "Nádraží Veleslavín", + "namesti-miru": "Náměstí Míru", + "namesti-republiky": "Náměstí Republiky", + "narodni-trida": "Národní třída", + "nemocnice-motol": "Nemocnice Motol", + "nove-butovice": "Nové Butovice", + opatov: "Opatov", + palmovka: "Palmovka", + pankrac: "Pankrác", + petriny: "Petřiny", + "prazskeho-povstani": "Pražského povstání", + prosek: "Prosek", + radlicka: "Radlická", + "rajska-zahrada": "Rajská zahrada", + roztyly: "Roztyly", + skalka: "Skalka", + "smichovske-nadrazi": "Smíchovské nádraží", + staromestska: "Staroměstská", + stodulky: "Stodůlky", + strasnicka: "Strašnická", + strizkov: "Střížkov", + vltavska: "Vltavská", + vysocanska: "Vysočanská", + vysehrad: "Vyšehrad", + zlicin: "Zličín", + zelivskeho: "Želivského", } as const; export type MetroStation = keyof typeof titleByMetroStation; export type MetroStationName = (typeof titleByMetroStation)[MetroStation]; export const platformsByMetroStation = { - andel: ['U1040Z101P', 'U1040Z102P'], - borislavka: ['U157Z101P', 'U157Z102P'], - budejovicka: ['U50Z101P', 'U50Z102P'], - 'cerny-most': ['U897Z101P'], - ceskomoravska: ['U510Z101P', 'U510Z102P'], - dejvicka: ['U321Z101P', 'U321Z102P'], - 'depo-hostivar': ['U1071Z101P', 'U1071Z102P'], - flora: ['U118Z101P', 'U118Z102P'], - florenc: ['U689Z101P', 'U689Z102P', 'U689Z121P', 'U689Z122P'], - haje: ['U286Z101P'], - 'hlavni-nadrazi': ['U142Z101P', 'U142Z102P'], - hloubetin: ['U135Z101P', 'U135Z102P'], - hradcanska: ['U163Z101P', 'U163Z102P'], - hurka: ['U1154Z101P', 'U1154Z102P'], - chodov: ['U52Z102P', 'U52Z101P'], - 'i-p-pavlova': ['U190Z101P', 'U190Z102P'], - invalidovna: ['U655Z101P', 'U655Z102P'], - jinonice: ['U685Z101P', 'U685Z102P'], - 'jiriho-z-podebrad': ['U209Z101P', 'U209Z102P'], - kacerov: ['U228Z101P', 'U228Z102P'], - 'karlovo-namesti': ['U237Z101P', 'U237Z102P'], - kobylisy: ['U675Z101P', 'U675Z102P'], - kolbenova: ['U75Z101P', 'U75Z102P'], - krizikova: ['U758Z101P', 'U758Z102P'], - ladvi: ['U78Z101P', 'U78Z102P'], - letnany: ['U1000Z102P'], - luka: ['U1007Z101P', 'U1007Z102P'], - luziny: ['U258Z101P', 'U258Z102P'], - malostranska: ['U360Z101P', 'U360Z102P'], - mustek: ['U1072Z101P', 'U1072Z102P', 'U1072Z121P', 'U1072Z122P'], - muzeum: ['U400Z101P', 'U400Z102P', 'U400Z121P', 'U400Z122P'], - 'nadrazi-holesovice': ['U115Z101P', 'U115Z102P'], - 'nadrazi-veleslavin': ['U462Z101P', 'U462Z102P'], - 'namesti-miru': ['U476Z101P', 'U476Z102P'], - 'namesti-republiky': ['U480Z101P', 'U480Z102P'], - 'narodni-trida': ['U539Z101P', 'U539Z102P'], - 'nemocnice-motol': ['U306Z101P'], - 'nove-butovice': ['U602Z101P', 'U602Z102P'], - opatov: ['U106Z101P', 'U106Z102P'], - palmovka: ['U529Z101P', 'U529Z102P'], - pankrac: ['U385Z101P', 'U385Z102P'], - petriny: ['U507Z101P', 'U507Z102P'], - 'prazskeho-povstani': ['U597Z101P', 'U597Z102P'], - prosek: ['U603Z101P', 'U603Z102P'], - radlicka: ['U957Z101P', 'U957Z102P'], - 'rajska-zahrada': ['U818Z101P', 'U818Z102P'], - roztyly: ['U601Z101P', 'U601Z102P'], - skalka: ['U953Z101P', 'U953Z102P'], - 'smichovske-nadrazi': ['U458Z101P', 'U458Z102P'], - staromestska: ['U703Z101P', 'U703Z102P'], - stodulky: ['U1140Z101P', 'U1140Z102P'], - strasnicka: ['U713Z101P', 'U713Z102P'], - strizkov: ['U332Z101P', 'U332Z102P'], - vltavska: ['U100Z101P', 'U100Z102P'], - vysocanska: ['U474Z101P', 'U474Z102P'], - vysehrad: ['U527Z101P', 'U527Z102P'], - zlicin: ['U1141Z102P'], - zelivskeho: ['U921Z101P', 'U921Z102P'], + andel: ["U1040Z101P", "U1040Z102P"], + borislavka: ["U157Z101P", "U157Z102P"], + budejovicka: ["U50Z101P", "U50Z102P"], + "cerny-most": ["U897Z101P"], + ceskomoravska: ["U510Z101P", "U510Z102P"], + dejvicka: ["U321Z101P", "U321Z102P"], + "depo-hostivar": ["U1071Z101P", "U1071Z102P"], + flora: ["U118Z101P", "U118Z102P"], + florenc: ["U689Z101P", "U689Z102P", "U689Z121P", "U689Z122P"], + haje: ["U286Z101P"], + "hlavni-nadrazi": ["U142Z101P", "U142Z102P"], + hloubetin: ["U135Z101P", "U135Z102P"], + hradcanska: ["U163Z101P", "U163Z102P"], + hurka: ["U1154Z101P", "U1154Z102P"], + chodov: ["U52Z102P", "U52Z101P"], + "i-p-pavlova": ["U190Z101P", "U190Z102P"], + invalidovna: ["U655Z101P", "U655Z102P"], + jinonice: ["U685Z101P", "U685Z102P"], + "jiriho-z-podebrad": ["U209Z101P", "U209Z102P"], + kacerov: ["U228Z101P", "U228Z102P"], + "karlovo-namesti": ["U237Z101P", "U237Z102P"], + kobylisy: ["U675Z101P", "U675Z102P"], + kolbenova: ["U75Z101P", "U75Z102P"], + krizikova: ["U758Z101P", "U758Z102P"], + ladvi: ["U78Z101P", "U78Z102P"], + letnany: ["U1000Z102P"], + luka: ["U1007Z101P", "U1007Z102P"], + luziny: ["U258Z101P", "U258Z102P"], + malostranska: ["U360Z101P", "U360Z102P"], + mustek: ["U1072Z101P", "U1072Z102P", "U1072Z121P", "U1072Z122P"], + muzeum: ["U400Z101P", "U400Z102P", "U400Z121P", "U400Z122P"], + "nadrazi-holesovice": ["U115Z101P", "U115Z102P"], + "nadrazi-veleslavin": ["U462Z101P", "U462Z102P"], + "namesti-miru": ["U476Z101P", "U476Z102P"], + "namesti-republiky": ["U480Z101P", "U480Z102P"], + "narodni-trida": ["U539Z101P", "U539Z102P"], + "nemocnice-motol": ["U306Z101P"], + "nove-butovice": ["U602Z101P", "U602Z102P"], + opatov: ["U106Z101P", "U106Z102P"], + palmovka: ["U529Z101P", "U529Z102P"], + pankrac: ["U385Z101P", "U385Z102P"], + petriny: ["U507Z101P", "U507Z102P"], + "prazskeho-povstani": ["U597Z101P", "U597Z102P"], + prosek: ["U603Z101P", "U603Z102P"], + radlicka: ["U957Z101P", "U957Z102P"], + "rajska-zahrada": ["U818Z101P", "U818Z102P"], + roztyly: ["U601Z101P", "U601Z102P"], + skalka: ["U953Z101P", "U953Z102P"], + "smichovske-nadrazi": ["U458Z101P", "U458Z102P"], + staromestska: ["U703Z101P", "U703Z102P"], + stodulky: ["U1140Z101P", "U1140Z102P"], + strasnicka: ["U713Z101P", "U713Z102P"], + strizkov: ["U332Z101P", "U332Z102P"], + vltavska: ["U100Z101P", "U100Z102P"], + vysocanska: ["U474Z101P", "U474Z102P"], + vysehrad: ["U527Z101P", "U527Z102P"], + zlicin: ["U1141Z102P"], + zelivskeho: ["U921Z101P", "U921Z102P"], } satisfies Record; diff --git a/backend-nest/src/data/platforms.ts b/backend-nest/src/data/platforms.ts index 03f394fe..2500f69f 100644 --- a/backend-nest/src/data/platforms.ts +++ b/backend-nest/src/data/platforms.ts @@ -1,121 +1,121 @@ export const platformIDs = [ - 'U1040Z101P', - 'U1040Z102P', - 'U157Z101P', - 'U157Z102P', - 'U50Z101P', - 'U50Z102P', - 'U897Z101P', - 'U510Z101P', - 'U510Z102P', - 'U321Z101P', - 'U321Z102P', - 'U1071Z101P', - 'U1071Z102P', - 'U118Z101P', - 'U118Z102P', - 'U689Z101P', - 'U689Z102P', - 'U689Z121P', - 'U689Z122P', - 'U286Z101P', - 'U142Z101P', - 'U142Z102P', - 'U135Z101P', - 'U135Z102P', - 'U163Z101P', - 'U163Z102P', - 'U1154Z101P', - 'U1154Z102P', - 'U52Z102P', - 'U52Z101P', - 'U190Z101P', - 'U190Z102P', - 'U655Z101P', - 'U655Z102P', - 'U685Z101P', - 'U685Z102P', - 'U209Z101P', - 'U209Z102P', - 'U228Z101P', - 'U228Z102P', - 'U237Z101P', - 'U237Z102P', - 'U675Z101P', - 'U675Z102P', - 'U75Z101P', - 'U75Z102P', - 'U758Z101P', - 'U758Z102P', - 'U78Z101P', - 'U78Z102P', - 'U1000Z102P', - 'U1007Z101P', - 'U1007Z102P', - 'U258Z101P', - 'U258Z102P', - 'U360Z101P', - 'U360Z102P', - 'U1072Z101P', - 'U1072Z102P', - 'U1072Z121P', - 'U1072Z122P', - 'U400Z101P', - 'U400Z102P', - 'U400Z121P', - 'U400Z122P', - 'U115Z101P', - 'U115Z102P', - 'U462Z101P', - 'U462Z102P', - 'U476Z101P', - 'U476Z102P', - 'U480Z101P', - 'U480Z102P', - 'U539Z101P', - 'U539Z102P', - 'U306Z101P', - 'U602Z101P', - 'U602Z102P', - 'U106Z101P', - 'U106Z102P', - 'U529Z101P', - 'U529Z102P', - 'U385Z101P', - 'U385Z102P', - 'U507Z101P', - 'U507Z102P', - 'U597Z101P', - 'U597Z102P', - 'U603Z101P', - 'U603Z102P', - 'U957Z101P', - 'U957Z102P', - 'U818Z101P', - 'U818Z102P', - 'U601Z101P', - 'U601Z102P', - 'U953Z101P', - 'U953Z102P', - 'U458Z101P', - 'U458Z102P', - 'U703Z101P', - 'U703Z102P', - 'U1140Z101P', - 'U1140Z102P', - 'U713Z101P', - 'U713Z102P', - 'U332Z101P', - 'U332Z102P', - 'U100Z101P', - 'U100Z102P', - 'U474Z101P', - 'U474Z102P', - 'U527Z101P', - 'U527Z102P', - 'U1141Z102P', - 'U921Z101P', - 'U921Z102P', + "U1040Z101P", + "U1040Z102P", + "U157Z101P", + "U157Z102P", + "U50Z101P", + "U50Z102P", + "U897Z101P", + "U510Z101P", + "U510Z102P", + "U321Z101P", + "U321Z102P", + "U1071Z101P", + "U1071Z102P", + "U118Z101P", + "U118Z102P", + "U689Z101P", + "U689Z102P", + "U689Z121P", + "U689Z122P", + "U286Z101P", + "U142Z101P", + "U142Z102P", + "U135Z101P", + "U135Z102P", + "U163Z101P", + "U163Z102P", + "U1154Z101P", + "U1154Z102P", + "U52Z102P", + "U52Z101P", + "U190Z101P", + "U190Z102P", + "U655Z101P", + "U655Z102P", + "U685Z101P", + "U685Z102P", + "U209Z101P", + "U209Z102P", + "U228Z101P", + "U228Z102P", + "U237Z101P", + "U237Z102P", + "U675Z101P", + "U675Z102P", + "U75Z101P", + "U75Z102P", + "U758Z101P", + "U758Z102P", + "U78Z101P", + "U78Z102P", + "U1000Z102P", + "U1007Z101P", + "U1007Z102P", + "U258Z101P", + "U258Z102P", + "U360Z101P", + "U360Z102P", + "U1072Z101P", + "U1072Z102P", + "U1072Z121P", + "U1072Z122P", + "U400Z101P", + "U400Z102P", + "U400Z121P", + "U400Z122P", + "U115Z101P", + "U115Z102P", + "U462Z101P", + "U462Z102P", + "U476Z101P", + "U476Z102P", + "U480Z101P", + "U480Z102P", + "U539Z101P", + "U539Z102P", + "U306Z101P", + "U602Z101P", + "U602Z102P", + "U106Z101P", + "U106Z102P", + "U529Z101P", + "U529Z102P", + "U385Z101P", + "U385Z102P", + "U507Z101P", + "U507Z102P", + "U597Z101P", + "U597Z102P", + "U603Z101P", + "U603Z102P", + "U957Z101P", + "U957Z102P", + "U818Z101P", + "U818Z102P", + "U601Z101P", + "U601Z102P", + "U953Z101P", + "U953Z102P", + "U458Z101P", + "U458Z102P", + "U703Z101P", + "U703Z102P", + "U1140Z101P", + "U1140Z102P", + "U713Z101P", + "U713Z102P", + "U332Z101P", + "U332Z102P", + "U100Z101P", + "U100Z102P", + "U474Z101P", + "U474Z102P", + "U527Z101P", + "U527Z102P", + "U1141Z102P", + "U921Z101P", + "U921Z102P", ] as const satisfies `U${number}Z${number}P`[]; export type PlatformID = (typeof platformIDs)[number]; diff --git a/backend-nest/src/main.ts b/backend-nest/src/main.ts index 7d4c1629..00a0a454 100644 --- a/backend-nest/src/main.ts +++ b/backend-nest/src/main.ts @@ -1,8 +1,8 @@ -import { NestFactory } from '@nestjs/core'; -import { AppModule } from './app.module'; +import { NestFactory } from "@nestjs/core"; +import { AppModule } from "./app.module"; async function bootstrap() { - const app = await NestFactory.create(AppModule); - await app.listen(3001); + const app = await NestFactory.create(AppModule); + await app.listen(3001); } bootstrap(); diff --git a/backend-nest/src/metro/__test__/metro.controller.spec.ts b/backend-nest/src/metro/__test__/metro.controller.spec.ts index 27fdf54a..f645ed3d 100644 --- a/backend-nest/src/metro/__test__/metro.controller.spec.ts +++ b/backend-nest/src/metro/__test__/metro.controller.spec.ts @@ -1,18 +1,18 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { MetroController } from '../metro.controller'; +import { Test, TestingModule } from "@nestjs/testing"; +import { MetroController } from "../metro.controller"; -describe('MetroController', () => { - let controller: MetroController; +describe("MetroController", () => { + let controller: MetroController; - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - controllers: [MetroController], - }).compile(); + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [MetroController], + }).compile(); - controller = module.get(MetroController); - }); + controller = module.get(MetroController); + }); - it('should be defined', () => { - expect(controller).toBeDefined(); - }); + it("should be defined", () => { + expect(controller).toBeDefined(); + }); }); diff --git a/backend-nest/src/metro/metro.controller.ts b/backend-nest/src/metro/metro.controller.ts index 8e8ddb36..956b8483 100644 --- a/backend-nest/src/metro/metro.controller.ts +++ b/backend-nest/src/metro/metro.controller.ts @@ -1,137 +1,139 @@ import { - Controller, - Get, - HttpException, - HttpStatus, - Query, -} from '@nestjs/common'; -import { parseMetroStation } from '../validation/metro-station'; + Controller, + Get, + HttpException, + HttpStatus, + Query, +} from "@nestjs/common"; +import { parseMetroStation } from "../validation/metro-station"; import { - platformsByMetroStation, - titleByMetroStation, -} from '../data/metro-stations'; -import { parseQueryParam } from '../utils/query-params'; -import { group, unique } from 'radash'; -import { platformIDs } from '../data/platforms'; -import type { MetroStationName } from '../data/metro-stations'; -import type { PlatformID } from '../data/platforms'; -import type { MetroLine, Timestamp } from '../types/types'; + platformsByMetroStation, + titleByMetroStation, +} from "../data/metro-stations"; +import { parseQueryParam } from "../utils/query-params"; +import { group, unique } from "radash"; +import { platformIDs } from "../data/platforms"; +import type { MetroStationName } from "../data/metro-stations"; +import type { PlatformID } from "../data/platforms"; +import type { MetroLine, Timestamp } from "../types/types"; import { - getDelayInSeconds, - getGolemioHeaders, - GOLEMIO_ENDPOINT, -} from '../utils/fetch'; + getDelayInSeconds, + getGolemioHeaders, + GOLEMIO_ENDPOINT, +} from "../utils/fetch"; -const ERROR_MSG = `Invalid "station" parameter. Supported stations: ${Object.keys(titleByMetroStation).join(', ')}`; +const ERROR_MSG = `Invalid "station" parameter. Supported stations: ${Object.keys(titleByMetroStation).join(", ")}`; const MAX_STATIONS = 10; type DepartureResponse = { - heading: MetroStationName; - line: MetroLine; - departure: string; - delay: number | null; // seconds - platform: PlatformID; + heading: MetroStationName; + line: MetroLine; + departure: string; + delay: number | null; // seconds + platform: PlatformID; }; type GetMetroResponse = { - [key in PlatformID]?: DepartureResponse[]; + [key in PlatformID]?: DepartureResponse[]; }; -@Controller('metro') +@Controller("metro") export class MetroController { - @Get() - async getMetroDepartures( - @Query('station') station?: string | string[], - ): Promise { - if (!station) { - throw new HttpException(ERROR_MSG, HttpStatus.BAD_REQUEST); - } + @Get() + async getMetroDepartures( + @Query("station") station?: string | string[], + ): Promise { + if (!station) { + throw new HttpException(ERROR_MSG, HttpStatus.BAD_REQUEST); + } - const stations = parseQueryParam(station); - if (!stations.length) { - throw new HttpException(ERROR_MSG, HttpStatus.BAD_REQUEST); - } + const stations = parseQueryParam(station); + if (!stations.length) { + throw new HttpException(ERROR_MSG, HttpStatus.BAD_REQUEST); + } - const parsedStations = stations.map(parseMetroStation); - if (parsedStations.includes(null)) { - throw new HttpException(ERROR_MSG, HttpStatus.BAD_REQUEST); - } else if (parsedStations.length > MAX_STATIONS) { - throw new HttpException( - `Too many stations. Maximum is ${MAX_STATIONS}.`, - HttpStatus.BAD_REQUEST, - ); - } + const parsedStations = stations.map(parseMetroStation); + if (parsedStations.includes(null)) { + throw new HttpException(ERROR_MSG, HttpStatus.BAD_REQUEST); + } else if (parsedStations.length > MAX_STATIONS) { + throw new HttpException( + `Too many stations. Maximum is ${MAX_STATIONS}.`, + HttpStatus.BAD_REQUEST, + ); + } - const res = await getDepartures( - parsedStations.flatMap((station) => platformsByMetroStation[station]), - ); + const res = await getDepartures( + parsedStations.flatMap( + (station) => platformsByMetroStation[station], + ), + ); - if (!res) { - throw new HttpException( - 'Failed to fetch data.', - HttpStatus.INTERNAL_SERVER_ERROR, - ); - } + if (!res) { + throw new HttpException( + "Failed to fetch data.", + HttpStatus.INTERNAL_SERVER_ERROR, + ); + } - return res; - } + return res; + } } type GolemioResponse = { - stops: { - stop_id: PlatformID; - stop_name: MetroStationName; - }[]; - departures: { - arrival_timestamp: Timestamp; - route: { - short_name: MetroLine; - }; - stop: { - id: string; - }; - delay: { - is_available: boolean; - minutes: number | undefined; - seconds: number | undefined; - }; - departure_timestamp: Timestamp; - trip: { - headsign: MetroStationName; - }; - }[]; + stops: { + stop_id: PlatformID; + stop_name: MetroStationName; + }[]; + departures: { + arrival_timestamp: Timestamp; + route: { + short_name: MetroLine; + }; + stop: { + id: string; + }; + delay: { + is_available: boolean; + minutes: number | undefined; + seconds: number | undefined; + }; + departure_timestamp: Timestamp; + trip: { + headsign: MetroStationName; + }; + }[]; }; const getDepartures = async ( - platforms: PlatformID[], + platforms: PlatformID[], ): Promise => { - const uniquePlatforms = unique(platforms); - if (!uniquePlatforms.every((id) => platformIDs.includes(id))) { - return null; - } + const uniquePlatforms = unique(platforms); + if (!uniquePlatforms.every((id) => platformIDs.includes(id))) { + return null; + } - const res = await fetch( - new URL( - `${GOLEMIO_ENDPOINT}?order=real&${uniquePlatforms.map((id) => `ids[]=${id}`).join('&')}`, - ), - { - method: 'GET', - headers: getGolemioHeaders(), - }, - ); + const res = await fetch( + new URL( + `${GOLEMIO_ENDPOINT}?order=real&${uniquePlatforms.map((id) => `ids[]=${id}`).join("&")}`, + ), + { + method: "GET", + headers: getGolemioHeaders(), + }, + ); - const parsedRes: GolemioResponse = await res.json(); - const parsedDepartures = parsedRes.departures.map((departure) => { - const { delay, departure_timestamp, trip, route, stop } = departure; + const parsedRes: GolemioResponse = await res.json(); + const parsedDepartures = parsedRes.departures.map((departure) => { + const { delay, departure_timestamp, trip, route, stop } = departure; - return { - delay: getDelayInSeconds(delay), - departure: departure_timestamp.predicted, - heading: trip.headsign, - line: route.short_name, - platform: stop.id as PlatformID, - }; - }); + return { + delay: getDelayInSeconds(delay), + departure: departure_timestamp.predicted, + heading: trip.headsign, + line: route.short_name, + platform: stop.id as PlatformID, + }; + }); - return group(parsedDepartures, (departure) => departure.platform); + return group(parsedDepartures, (departure) => departure.platform); }; diff --git a/backend-nest/src/types/types.ts b/backend-nest/src/types/types.ts index 517980f0..48d42357 100644 --- a/backend-nest/src/types/types.ts +++ b/backend-nest/src/types/types.ts @@ -1,12 +1,12 @@ -export type MetroLine = 'A' | 'B' | 'C'; +export type MetroLine = "A" | "B" | "C"; export type Timestamp = { - predicted: string; - scheduled: string; + predicted: string; + scheduled: string; }; export type Delay = { - is_available?: unknown; - minutes?: unknown; - seconds?: unknown; + is_available?: unknown; + minutes?: unknown; + seconds?: unknown; }; diff --git a/backend-nest/src/utils/__test__/fetch.spec.ts b/backend-nest/src/utils/__test__/fetch.spec.ts index b015f207..6d64ccf1 100644 --- a/backend-nest/src/utils/__test__/fetch.spec.ts +++ b/backend-nest/src/utils/__test__/fetch.spec.ts @@ -1,56 +1,56 @@ -import { getDelayInSeconds } from '../fetch'; - -describe('getDelayInSeconds', () => { - it('should return 0 when delay is undefined', () => { - expect(getDelayInSeconds(undefined)).toBe(0); - }); - - it('should return 0 when delay is null', () => { - expect(getDelayInSeconds(null)).toBe(0); - }); - - it('should return seconds when delay contains seconds only', () => { - const delay = { seconds: 30 }; - expect(getDelayInSeconds(delay)).toBe(30); - }); - - it('should return minutes converted to seconds when delay contains minutes only', () => { - const delay = { minutes: 2 }; - expect(getDelayInSeconds(delay)).toBe(120); // 2 minutes = 120 seconds - }); - - it('should return combined seconds and minutes when both are present in delay', () => { - const delay = { seconds: 45, minutes: 1 }; - expect(getDelayInSeconds(delay)).toBe(105); // 1 minute + 45 seconds = 60 + 45 = 105 seconds - }); - - it('should return 0 when delay is an empty object', () => { - const delay = {}; - expect(getDelayInSeconds(delay)).toBe(0); - }); - - it('should return 0 when delay seconds and minutes are not numbers', () => { - const delay = { seconds: 'invalid', minutes: 'invalid' }; - expect(getDelayInSeconds(delay)).toBe(0); - }); - - it('should handle negative seconds correctly', () => { - const delay = { seconds: -15 }; - expect(getDelayInSeconds(delay)).toBe(-15); // Negative seconds should be returned as negative - }); - - it('should handle negative minutes correctly', () => { - const delay = { minutes: -1 }; - expect(getDelayInSeconds(delay)).toBe(-60); // Negative minutes should convert to negative seconds - }); - - it('should handle combined negative values correctly', () => { - const delay = { seconds: -30, minutes: -1 }; - expect(getDelayInSeconds(delay)).toBe(-90); // Combined negative values should sum as negative seconds - }); - - it('should handle negative seconds and positive minutes correctly', () => { - const delay = { seconds: -30, minutes: 2 }; - expect(getDelayInSeconds(delay)).toBe(90); // 2 minutes should override negative seconds - }); +import { getDelayInSeconds } from "../fetch"; + +describe("getDelayInSeconds", () => { + it("should return 0 when delay is undefined", () => { + expect(getDelayInSeconds(undefined)).toBe(0); + }); + + it("should return 0 when delay is null", () => { + expect(getDelayInSeconds(null)).toBe(0); + }); + + it("should return seconds when delay contains seconds only", () => { + const delay = { seconds: 30 }; + expect(getDelayInSeconds(delay)).toBe(30); + }); + + it("should return minutes converted to seconds when delay contains minutes only", () => { + const delay = { minutes: 2 }; + expect(getDelayInSeconds(delay)).toBe(120); // 2 minutes = 120 seconds + }); + + it("should return combined seconds and minutes when both are present in delay", () => { + const delay = { seconds: 45, minutes: 1 }; + expect(getDelayInSeconds(delay)).toBe(105); // 1 minute + 45 seconds = 60 + 45 = 105 seconds + }); + + it("should return 0 when delay is an empty object", () => { + const delay = {}; + expect(getDelayInSeconds(delay)).toBe(0); + }); + + it("should return 0 when delay seconds and minutes are not numbers", () => { + const delay = { seconds: "invalid", minutes: "invalid" }; + expect(getDelayInSeconds(delay)).toBe(0); + }); + + it("should handle negative seconds correctly", () => { + const delay = { seconds: -15 }; + expect(getDelayInSeconds(delay)).toBe(-15); // Negative seconds should be returned as negative + }); + + it("should handle negative minutes correctly", () => { + const delay = { minutes: -1 }; + expect(getDelayInSeconds(delay)).toBe(-60); // Negative minutes should convert to negative seconds + }); + + it("should handle combined negative values correctly", () => { + const delay = { seconds: -30, minutes: -1 }; + expect(getDelayInSeconds(delay)).toBe(-90); // Combined negative values should sum as negative seconds + }); + + it("should handle negative seconds and positive minutes correctly", () => { + const delay = { seconds: -30, minutes: 2 }; + expect(getDelayInSeconds(delay)).toBe(90); // 2 minutes should override negative seconds + }); }); diff --git a/backend-nest/src/utils/__test__/remove-diacritics.spec.ts b/backend-nest/src/utils/__test__/remove-diacritics.spec.ts index 3bbf43f9..c32f86cd 100644 --- a/backend-nest/src/utils/__test__/remove-diacritics.spec.ts +++ b/backend-nest/src/utils/__test__/remove-diacritics.spec.ts @@ -1,33 +1,33 @@ -import { removeDiacritics } from '../remove-diacritics'; +import { removeDiacritics } from "../remove-diacritics"; -describe('removeDiacritics', () => { - it('should remove diacritics from a string', () => { - const input = 'áéíóúüñãç'; - const expected = 'aeiouunac'; - expect(removeDiacritics(input)).toBe(expected); - }); +describe("removeDiacritics", () => { + it("should remove diacritics from a string", () => { + const input = "áéíóúüñãç"; + const expected = "aeiouunac"; + expect(removeDiacritics(input)).toBe(expected); + }); - it('should handle empty string', () => { - const input = ''; - const expected = ''; - expect(removeDiacritics(input)).toBe(expected); - }); + it("should handle empty string", () => { + const input = ""; + const expected = ""; + expect(removeDiacritics(input)).toBe(expected); + }); - it('should handle string without diacritics', () => { - const input = 'abcdef'; - const expected = 'abcdef'; - expect(removeDiacritics(input)).toBe(expected); - }); + it("should handle string without diacritics", () => { + const input = "abcdef"; + const expected = "abcdef"; + expect(removeDiacritics(input)).toBe(expected); + }); - it('should handle mixed string with and without diacritics', () => { - const input = 'áéí123óú456üñ789ãç'; - const expected = 'aei123ou456un789ac'; - expect(removeDiacritics(input)).toBe(expected); - }); + it("should handle mixed string with and without diacritics", () => { + const input = "áéí123óú456üñ789ãç"; + const expected = "aei123ou456un789ac"; + expect(removeDiacritics(input)).toBe(expected); + }); - it('should handle string with multiple occurrences of the same diacritic', () => { - const input = 'ááááá'; - const expected = 'aaaaa'; - expect(removeDiacritics(input)).toBe(expected); - }); + it("should handle string with multiple occurrences of the same diacritic", () => { + const input = "ááááá"; + const expected = "aaaaa"; + expect(removeDiacritics(input)).toBe(expected); + }); }); diff --git a/backend-nest/src/utils/fetch.ts b/backend-nest/src/utils/fetch.ts index 2db6f018..3d275f23 100644 --- a/backend-nest/src/utils/fetch.ts +++ b/backend-nest/src/utils/fetch.ts @@ -1,30 +1,30 @@ -import { Delay } from 'src/types/types'; +import { Delay } from "src/types/types"; export const GOLEMIO_ENDPOINT = new URL( - '/v2/pid/departureboards', - 'https://api.golemio.cz', + "/v2/pid/departureboards", + "https://api.golemio.cz", ); export const getGolemioHeaders = () => { - return new Headers({ - 'Content-Type': 'application/json', - 'X-Access-Token': process.env.GOLEMIO_API_KEY, - }); + return new Headers({ + "Content-Type": "application/json", + "X-Access-Token": process.env.GOLEMIO_API_KEY, + }); }; export const getDelayInSeconds = (delay?: Delay | null): number => { - if (!delay) { - return 0; - } + if (!delay) { + return 0; + } - let seconds = 0; + let seconds = 0; - if (typeof delay?.seconds === 'number') { - seconds += delay.seconds; - } - if (typeof delay?.minutes === 'number') { - seconds += delay.minutes * 60; - } + if (typeof delay?.seconds === "number") { + seconds += delay.seconds; + } + if (typeof delay?.minutes === "number") { + seconds += delay.minutes * 60; + } - return seconds; + return seconds; }; diff --git a/backend-nest/src/utils/query-params.ts b/backend-nest/src/utils/query-params.ts index 1e3588d4..e1881167 100644 --- a/backend-nest/src/utils/query-params.ts +++ b/backend-nest/src/utils/query-params.ts @@ -1,21 +1,21 @@ export const parseQueryParam = ( - param: string | string[] | undefined, + param: string | string[] | undefined, ): string[] | null => { - if (!param) { - return null; - } + if (!param) { + return null; + } - if (param instanceof Array) { - return param.length === 0 ? null : param; - } + if (param instanceof Array) { + return param.length === 0 ? null : param; + } - if (param.startsWith('[') && param.endsWith(']')) { - try { - return JSON.parse(param); - } catch { - return param.slice(1, -1).split(','); + if (param.startsWith("[") && param.endsWith("]")) { + try { + return JSON.parse(param); + } catch { + return param.slice(1, -1).split(","); + } } - } - return [param]; + return [param]; }; diff --git a/backend-nest/src/utils/remove-diacritics.ts b/backend-nest/src/utils/remove-diacritics.ts index 146834bb..07442e56 100644 --- a/backend-nest/src/utils/remove-diacritics.ts +++ b/backend-nest/src/utils/remove-diacritics.ts @@ -1,3 +1,3 @@ export const removeDiacritics = (str: string): string => { - return str.normalize('NFD').replace(/\p{Diacritic}/gu, ''); + return str.normalize("NFD").replace(/\p{Diacritic}/gu, ""); }; diff --git a/backend-nest/src/validation/metro-station.ts b/backend-nest/src/validation/metro-station.ts index a57dff4c..5ec6b3f1 100644 --- a/backend-nest/src/validation/metro-station.ts +++ b/backend-nest/src/validation/metro-station.ts @@ -1,20 +1,20 @@ -import { titleByMetroStation, MetroStation } from '../data/metro-stations'; -import { removeDiacritics } from '../utils/remove-diacritics'; +import { titleByMetroStation, MetroStation } from "../data/metro-stations"; +import { removeDiacritics } from "../utils/remove-diacritics"; export const parseMetroStation = ( - station: string | undefined, + station: string | undefined, ): MetroStation | null => { - if (!station) { - return null; - } + if (!station) { + return null; + } - const parsed = removeDiacritics( - station.toLowerCase().replaceAll(' ', '-').replaceAll('.', ''), - ); + const parsed = removeDiacritics( + station.toLowerCase().replaceAll(" ", "-").replaceAll(".", ""), + ); - if (parsed in titleByMetroStation) { - return parsed as MetroStation; - } + if (parsed in titleByMetroStation) { + return parsed as MetroStation; + } - return null; + return null; }; diff --git a/backend-nest/test/app.e2e-spec.ts b/backend-nest/test/app.e2e-spec.ts index 50cda623..bca77fda 100644 --- a/backend-nest/test/app.e2e-spec.ts +++ b/backend-nest/test/app.e2e-spec.ts @@ -1,24 +1,24 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { INestApplication } from '@nestjs/common'; -import * as request from 'supertest'; -import { AppModule } from './../src/app.module'; +import { Test, TestingModule } from "@nestjs/testing"; +import { INestApplication } from "@nestjs/common"; +import * as request from "supertest"; +import { AppModule } from "./../src/app.module"; -describe('AppController (e2e)', () => { - let app: INestApplication; +describe("AppController (e2e)", () => { + let app: INestApplication; - beforeEach(async () => { - const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], - }).compile(); + beforeEach(async () => { + const moduleFixture: TestingModule = await Test.createTestingModule({ + imports: [AppModule], + }).compile(); - app = moduleFixture.createNestApplication(); - await app.init(); - }); + app = moduleFixture.createNestApplication(); + await app.init(); + }); - it('/ (GET)', () => { - return request(app.getHttpServer()) - .get('/') - .expect(200) - .expect('Hello World!'); - }); + it("/ (GET)", () => { + return request(app.getHttpServer()) + .get("/") + .expect(200) + .expect("Hello World!"); + }); }); diff --git a/backend-nest/test/jest-e2e.json b/backend-nest/test/jest-e2e.json index e9d912f3..055b528d 100644 --- a/backend-nest/test/jest-e2e.json +++ b/backend-nest/test/jest-e2e.json @@ -1,9 +1,9 @@ { - "moduleFileExtensions": ["js", "json", "ts"], - "rootDir": ".", - "testEnvironment": "node", - "testRegex": ".e2e-spec.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - } + "moduleFileExtensions": ["js", "json", "ts"], + "rootDir": ".", + "testEnvironment": "node", + "testRegex": ".e2e-spec.ts$", + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + } } diff --git a/backend-nest/tsconfig.build.json b/backend-nest/tsconfig.build.json index 64f86c6b..aed3485a 100644 --- a/backend-nest/tsconfig.build.json +++ b/backend-nest/tsconfig.build.json @@ -1,4 +1,4 @@ { - "extends": "./tsconfig.json", - "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] + "extends": "./tsconfig.json", + "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] } diff --git a/backend-nest/tsconfig.json b/backend-nest/tsconfig.json index 95f5641c..dd264f7e 100644 --- a/backend-nest/tsconfig.json +++ b/backend-nest/tsconfig.json @@ -1,21 +1,21 @@ { - "compilerOptions": { - "module": "commonjs", - "declaration": true, - "removeComments": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "allowSyntheticDefaultImports": true, - "target": "ES2021", - "sourceMap": true, - "outDir": "./dist", - "baseUrl": "./", - "incremental": true, - "skipLibCheck": true, - "strictNullChecks": false, - "noImplicitAny": false, - "strictBindCallApply": false, - "forceConsistentCasingInFileNames": false, - "noFallthroughCasesInSwitch": false - } + "compilerOptions": { + "module": "commonjs", + "declaration": true, + "removeComments": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "ES2021", + "sourceMap": true, + "outDir": "./dist", + "baseUrl": "./", + "incremental": true, + "skipLibCheck": true, + "strictNullChecks": false, + "noImplicitAny": false, + "strictBindCallApply": false, + "forceConsistentCasingInFileNames": false, + "noFallthroughCasesInSwitch": false + } } diff --git a/turbo.json b/turbo.json index 9a35cb3b..7513079b 100644 --- a/turbo.json +++ b/turbo.json @@ -1,7 +1,6 @@ { "$schema": "https://turbo.build/schema.json", "globalDependencies": ["**/.env"], - "experimentalUI": true, "pipeline": { "build": { "outputs": [".next/**", "!.next/cache/**", "^build"], @@ -17,28 +16,28 @@ "persistent": true }, "//#format:swift": { - "cache": true, + "cache": false, "inputs": ["**/**.swift"] }, "//#format:prettier": { - "cache": true, + "cache": false, "inputs": ["!app/**", "!**/node_modules/**"] }, "//#format:swift:check": { - "cache": true, + "cache": false, "inputs": ["**/**.swift"] }, "//#format:prettier:check": { - "cache": true, + "cache": false, "inputs": ["!app/**", "!**/node_modules/**"] }, "format": { "dependsOn": ["//#format:swift", "//#format:prettier"], - "cache": true + "cache": false }, "format:check": { "dependsOn": ["//#format:swift:check", "//#format:prettier:check"], - "cache": true + "cache": false }, "precommit": { "dependsOn": ["format", "build", "typecheck"]