Add E2E tests and update dependencies
Implemented end-to-end tests for the app and introduced path aliases in `tsconfig.json`. Updated `pnpm-lock.yaml` with the latest dependency versions. Added a new service method to fetch offers by user ID and crypto ID.
This commit is contained in:
parent
8ea217fe9f
commit
ecba9a3377
45
biome.json
Normal file
45
biome.json
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
|
||||
"organizeImports": {
|
||||
"enabled": true
|
||||
},
|
||||
"files": {
|
||||
"include": [
|
||||
"./src/**/*.ts",
|
||||
"./src/**/*.tsx"
|
||||
]
|
||||
},
|
||||
"vcs": {
|
||||
"enabled": true,
|
||||
"clientKind": "git"
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": true,
|
||||
"performance": {
|
||||
"recommended": true,
|
||||
"noDelete": "off"
|
||||
},
|
||||
"suspicious": {
|
||||
"noExplicitAny": "warn"
|
||||
},
|
||||
"complexity": {
|
||||
"useLiteralKeys": "off"
|
||||
},
|
||||
"style": {
|
||||
"useImportType": "off"
|
||||
}
|
||||
}
|
||||
},
|
||||
"formatter": {
|
||||
"indentStyle": "tab",
|
||||
"indentWidth": 2,
|
||||
"lineWidth": 90
|
||||
},
|
||||
"javascript": {
|
||||
"parser": {
|
||||
"unsafeParameterDecoratorsEnabled": true
|
||||
}
|
||||
}
|
||||
}
|
@ -11,4 +11,4 @@ services:
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_DB: ${POSTGRES_DATABASE}
|
||||
volumes:
|
||||
- './db-data/:/var/lib/postgresql/data/'
|
||||
- '${PWD}/db-data/:/var/lib/postgresql/data/'
|
20
package.json
20
package.json
@ -9,6 +9,8 @@
|
||||
"seed": "ts-node prisma/seed.ts"
|
||||
},
|
||||
"scripts": {
|
||||
"check": "biome check --skip-errors src",
|
||||
"fix": "biome check --skip-errors --write src",
|
||||
"build": "nest build",
|
||||
"start": "nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
@ -21,15 +23,15 @@
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^10.4.6",
|
||||
"@nestjs/common": "^10.4.7",
|
||||
"@nestjs/config": "^3.3.0",
|
||||
"@nestjs/core": "^10.4.6",
|
||||
"@nestjs/core": "^10.4.7",
|
||||
"@nestjs/jwt": "^10.2.0",
|
||||
"@nestjs/passport": "^10.0.3",
|
||||
"@nestjs/platform-express": "^10.4.6",
|
||||
"@nestjs/platform-express": "^10.4.7",
|
||||
"@nestjs/swagger": "^7.4.2",
|
||||
"@nestjs/throttler": "^5.2.0",
|
||||
"@prisma/client": "^5.21.1",
|
||||
"@prisma/client": "^5.22.0",
|
||||
"@prisma/studio": "^0.497.0",
|
||||
"@types/nodemailer": "^6.4.16",
|
||||
"argon2": "^0.31.2",
|
||||
@ -41,22 +43,24 @@
|
||||
"nodemailer": "^6.9.16",
|
||||
"passport": "^0.7.0",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"prisma": "^5.21.1",
|
||||
"prisma": "^5.22.0",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rimraf": "^5.0.10",
|
||||
"rxjs": "^7.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^10.4.5",
|
||||
"@biomejs/biome": "^1.9.4",
|
||||
"@nestjs/cli": "^10.4.7",
|
||||
"@nestjs/schematics": "^10.2.3",
|
||||
"@nestjs/testing": "^10.4.6",
|
||||
"@nestjs/testing": "^10.4.7",
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^20.17.4",
|
||||
"@types/node": "^20.17.6",
|
||||
"@types/passport-jwt": "^3.0.13",
|
||||
"@types/supertest": "^6.0.2",
|
||||
"dotenv-cli": "^4.1.1",
|
||||
"jest": "^29.7.0",
|
||||
"jest-mock-extended": "4.0.0-beta1",
|
||||
"source-map-support": "^0.5.21",
|
||||
"supertest": "^6.3.4",
|
||||
"ts-jest": "^29.2.5",
|
||||
|
569
pnpm-lock.yaml
generated
569
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -55,4 +55,10 @@ export class OfferController {
|
||||
deleteOfferById(@Param("id") roleId: string, @GetUser() user: User) {
|
||||
return this.offerService.deleteOfferById(user.id, roleId);
|
||||
}
|
||||
|
||||
@HttpCode(HttpStatus.FOUND)
|
||||
@Get("crypto/:cryptoId")
|
||||
getOffersById(@GetUser() user: User,@Param("cryptoId") cryptoId: string) {
|
||||
this.offerService.getOffersById(user.id, cryptoId)
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,25 @@ export class OfferService {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async getOffersById(userId: string, cryptoId: string) {
|
||||
await checkUserHasAccount(userId);
|
||||
return this.prisma.offer.findMany({
|
||||
where: {
|
||||
id_crypto: cryptoId,
|
||||
},
|
||||
orderBy: {
|
||||
created_at: "desc",
|
||||
},
|
||||
select: {
|
||||
amount: true,
|
||||
created_at: true,
|
||||
id_user: true,
|
||||
Crypto: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async editOfferById(userId: string, offerId: string, dto: OfferDto) {
|
||||
await checkUserHasAccount(userId);
|
||||
|
||||
|
24
test/app.e2e-spec.ts
Normal file
24
test/app.e2e-spec.ts
Normal file
@ -0,0 +1,24 @@
|
||||
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;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
});
|
9
test/jest-e2e.json
Normal file
9
test/jest-e2e.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
@ -16,6 +16,9 @@
|
||||
"noImplicitAny": false,
|
||||
"strictBindCallApply": false,
|
||||
"forceConsistentCasingInFileNames": false,
|
||||
"noFallthroughCasesInSwitch": false
|
||||
"noFallthroughCasesInSwitch": false,
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user