Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:generating docs #95

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions backend/commands/docs_generate.ts
Original file line number Diff line number Diff line change
@@ -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)
}
}
12 changes: 6 additions & 6 deletions backend/config/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
14 changes: 13 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
version: "3.8"

services:
db:
image: postgres:16-alpine
Expand All @@ -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:
db-data:
Loading