From 42e26c89c764cd351e5c0d35bd4046c0888c2532 Mon Sep 17 00:00:00 2001 From: unewMe Date: Fri, 22 Nov 2024 17:10:08 +0100 Subject: [PATCH] fix:generating docs --- backend/commands/docs_generate.ts | 19 +++++++++++++++++++ backend/config/swagger.ts | 12 ++++++------ docker-compose.yml | 14 +++++++++++++- 3 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 backend/commands/docs_generate.ts diff --git a/backend/commands/docs_generate.ts b/backend/commands/docs_generate.ts new file mode 100644 index 0000000..b2e79cb --- /dev/null +++ b/backend/commands/docs_generate.ts @@ -0,0 +1,19 @@ +import { BaseCommand } from '@adonisjs/core/ace' +import { CommandOptions } from '@adonisjs/core/types/ace' +import AutoSwagger from 'adonis-autoswagger' +import swagger from '#config/swagger' +export default class DocsGenerate extends BaseCommand { + static commandName = 'docs:generate' + + static options: CommandOptions = { + startApp: true, + allowUnknownFlags: false, + staysAlive: false, + } + + async run() { + const Router = await this.app.container.make('router') + Router.commit() + await AutoSwagger.default.writeFile(Router.toJSON(), swagger) + } +} diff --git a/backend/config/swagger.ts b/backend/config/swagger.ts index 0bacb03..cf5e672 100644 --- a/backend/config/swagger.ts +++ b/backend/config/swagger.ts @@ -6,14 +6,14 @@ import url from 'node:url' export default { // path: __dirname + "/../", for AdonisJS v5 path: path.dirname(url.fileURLToPath(import.meta.url)) + '/../', // for AdonisJS v6 - title: 'Foo', // use info instead - version: '1.0.0', // use info instead - description: '', // use info instead + title: 'Planer v1.5 API Docs', // use info instead + version: '1.5.1', // use info instead + description: 'The best planning tool for students. Made with <3', // use info instead tagIndex: 2, info: { - title: 'title', - version: '1.0.0', - description: '', + title: 'Planer v1.5 API Docs', + version: '1.5.1', + description: 'The best planning tool for students. Made with <3', }, snakeCase: true, diff --git a/docker-compose.yml b/docker-compose.yml index 4a53dbb..2e68377 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,5 @@ +version: "3.8" + services: db: image: postgres:16-alpine @@ -11,5 +13,15 @@ services: volumes: - db-data:/var/lib/postgresql/data + app: + build: + context: . + dockerfile: Dockerfile + depends_on: + - db + ports: + - 3000:3000 + command: sh -c "node ace docs:generate && node ace build --production && cp swagger.yml build/ && node server.js" + volumes: - db-data: \ No newline at end of file + db-data: