limited swagger docs enabled; minor refactoring

main
Inga 🏳‍🌈 1 year ago
parent 97d4d55381
commit 8e521876e7
  1. 60
      package-lock.json
  2. 1
      package.json
  3. 7
      src/app.module.spec.ts
  4. 4
      src/main.ts
  5. 13
      src/utils/nestjsHelpers.ts
  6. 6
      test/app.e2e-spec.ts

60
package-lock.json generated

@ -13,6 +13,7 @@
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^7.1.16",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"node-fetch": "^2.7.0",
@ -1680,6 +1681,25 @@
}
}
},
"node_modules/@nestjs/mapped-types": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-2.0.3.tgz",
"integrity": "sha512-40Zdqg98lqoF0+7ThWIZFStxgzisK6GG22+1ABO4kZiGF/Tu2FE+DYLw+Q9D94vcFWizJ+MSjNN4ns9r6hIGxw==",
"peerDependencies": {
"@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0",
"class-transformer": "^0.4.0 || ^0.5.0",
"class-validator": "^0.13.0 || ^0.14.0",
"reflect-metadata": "^0.1.12"
},
"peerDependenciesMeta": {
"class-transformer": {
"optional": true
},
"class-validator": {
"optional": true
}
}
},
"node_modules/@nestjs/platform-express": {
"version": "10.2.10",
"resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.2.10.tgz",
@ -1716,6 +1736,37 @@
"typescript": ">=4.8.2"
}
},
"node_modules/@nestjs/swagger": {
"version": "7.1.16",
"resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-7.1.16.tgz",
"integrity": "sha512-f9KBk/BX9MUKPTj7tQNYJ124wV/jP5W2lwWHLGwe/4qQXixuDOo39zP55HIJ44LE7S04B7BOeUOo9GBJD/vRcw==",
"dependencies": {
"@nestjs/mapped-types": "2.0.3",
"js-yaml": "4.1.0",
"lodash": "4.17.21",
"path-to-regexp": "3.2.0",
"swagger-ui-dist": "5.9.1"
},
"peerDependencies": {
"@fastify/static": "^6.0.0",
"@nestjs/common": "^9.0.0 || ^10.0.0",
"@nestjs/core": "^9.0.0 || ^10.0.0",
"class-transformer": "*",
"class-validator": "*",
"reflect-metadata": "^0.1.12"
},
"peerDependenciesMeta": {
"@fastify/static": {
"optional": true
},
"class-transformer": {
"optional": true
},
"class-validator": {
"optional": true
}
}
},
"node_modules/@nestjs/testing": {
"version": "10.2.10",
"resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-10.2.10.tgz",
@ -2682,8 +2733,7 @@
"node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
},
"node_modules/array-flatten": {
"version": "1.1.1",
@ -6103,7 +6153,6 @@
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"dev": true,
"dependencies": {
"argparse": "^2.0.1"
},
@ -8040,6 +8089,11 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/swagger-ui-dist": {
"version": "5.9.1",
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.9.1.tgz",
"integrity": "sha512-5zAx+hUwJb9T3EAntc7TqYkV716CMqG6sZpNlAAMOMWkNXRYxGkN8ADIvD55dQZ10LxN90ZM/TQmN7y1gpICnw=="
},
"node_modules/symbol-observable": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-4.0.0.tgz",

@ -24,6 +24,7 @@
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^7.1.16",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"node-fetch": "^2.7.0",

@ -1,8 +1,9 @@
import { Test, type TestingModule } from '@nestjs/testing';
import { ValidationPipe, type INestApplication } from '@nestjs/common';
import type { INestApplication } from '@nestjs/common';
import request from 'supertest';
import { AppModule } from './../src/app.module';
import { AppModule } from './app.module';
import { createTestOmdbEnrichedDataService } from './utils/testHelpers';
import { configureApp } from './utils/nestjsHelpers';
describe('AppController (e2e)', () => {
let app: INestApplication;
@ -18,7 +19,7 @@ describe('AppController (e2e)', () => {
.compile();
app = moduleFixture.createNestApplication();
app.useGlobalPipes(new ValidationPipe({ transform: true }));
configureApp(app);
await app.init();
});

@ -1,10 +1,10 @@
import { ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { configureApp } from './utils/nestjsHelpers';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(new ValidationPipe({ transform: true }));
configureApp(app);
await app.listen(3000);
}
void bootstrap();

@ -0,0 +1,13 @@
import { type INestApplication, ValidationPipe } from '@nestjs/common';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
export const configureApp = (app: INestApplication<unknown>) => {
app.useGlobalPipes(new ValidationPipe({ transform: true }));
const config = new DocumentBuilder()
.setTitle('Test joyn assignment')
.setVersion('1.0')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api', app, document);
};

@ -1,17 +1,19 @@
import { Test, type TestingModule } from '@nestjs/testing';
import type { INestApplication } from '@nestjs/common';
import request from 'supertest';
import { AppModule } from './../src/app.module';
import { AppModule } from '../src/app.module';
import { configureApp } from '../src/utils/nestjsHelpers';
describe('AppController (e2e)', () => {
let app: INestApplication;
beforeEach(async () => {
beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
configureApp(app);
await app.init();
});

Loading…
Cancel
Save