| 1 | import 'dotenv/config'; |
| 2 | import { writeFileSync } |
| 3 | import morgan from 'morgan |
| 4 | |
| 5 | import { ValidationPipe, VersioningType |
| 6 | import { NestFactory } |
| 7 | import { NestExpressApplication } |
| 8 | import { DocumentBuilder, SwaggerModule |
| 9 | import { apiReference } |
| 10 | import { Request, Response |
| 11 | |
| 12 | import { AppModule } |
| 13 | |
| 14 | async function bootstrap() |
| 15 | const app = |
| 16 | app.use(morgan |
| 17 | app.enableCors(); |
| 18 | app.getHttpAdapter().get |
| 19 | return res.json |
| 20 | [{ |
| 21 | "relation": ["delegate_permission/common.handle_all_urls" |
| 22 | "target": { |
| 23 | "namespace": "android_app", |
| 24 | "package_name": "com.phantomknight287.planepal", |
| 25 | "sha256_cert_fingerprints": |
| 26 | ["9E:A9:13:EE:1A:D2:F8:58:56:8F:EA:F4:5E:61:CE:29:11:0A:1A:2B:59:4B:2B:43:07:1F:9A:2F:9F:71:FE:D4"] |
| 27 | } |
| 28 | }] |
| 29 | ) |
| 30 | }) |
| 31 | |
| 32 | app.enableVersioning({ |
| 33 | type: VersioningType.URI |
| 34 | defaultVersion: '1', |
| 35 | }); |
| 36 | app.useGlobalPipes( |
| 37 | new ValidationPipe({ |
| 38 | ); |
| 39 | const config = |
| 40 | .setTitle('Plane Pal') |
| 41 | .setDescription('Plane Pal API Documentation') |
| 42 | .addBearerAuth( |
| 43 | { |
| 44 | type: 'http', |
| 45 | scheme: 'bearer', |
| 46 | bearerFormat: 'JWT', |
| 47 | }, |
| 48 | 'JWT-auth', |
| 49 | ) |
| 50 | .build(); |
| 51 | |
| 52 | const document = |
| 53 | Object.values(document |
| 54 | Object.values(path |
| 55 | if (!method.responses |
| 56 | method.responses = |
| 57 | } |
| 58 | method.responses['500 |
| 59 | description: 'Internal server error', |
| 60 | content: { |
| 61 | 'application/json': { |
| 62 | schema: { |
| 63 | $ref: '#/components/schemas/GenericErrorEntity', |
| 64 | }, |
| 65 | }, |
| 66 | }, |
| 67 | }; |
| 68 | }); |
| 69 | }); |
| 70 | writeFileSync('./openapi.json', |
| 71 | app.use( |
| 72 | '/docs', |
| 73 | apiReference({ |
| 74 | spec: { |
| 75 | content: document, |
| 76 | }, |
| 77 | layout: 'modern', |
| 78 | isEditable: false, |
| 79 | metaData: { |
| 80 | title: 'Plane Pal', |
| 81 | description: 'Plane Pal API Documentation', |
| 82 | }, |
| 83 | }), |
| 84 | ); |
| 85 | await app.listen |
| 86 | } |
| 87 | bootstrap(); |