koagger
v0.3.0
Published
A Koa middleware provides Swagger API document & Mock API for routing-controllers framework
Downloads
36
Maintainers
Readme
Koagger
A Koa middleware provides Swagger API document & Mock API for routing-controllers framework.
Usage
npm install koagger
index.ts
import Koa from 'koa';
import { useKoaServer } from 'routing-controllers';
import { createAPI } from 'koagger';
import controllers from './controller';
const { PORT = 8080 } = process.env,
{ swagger, mocker, router } = createAPI({ controllers, mock: true });
const HOST = `http://localhost:${PORT}`,
app = new Koa().use(swagger()).use(mocker());
useKoaServer(app, router);
app.listen(PORT, () =>
console.log(`
HTTP served at ${HOST}
Swagger API served at ${HOST}/docs/
Mock API served at ${HOST}/mock/
`)
);
Development
git clone https://github.com/idea2app/Koagger.git ~/Desktop/Koagger
cd ~/Desktop/Koagger
yarn
yarn dev # or just press F5 key in VS Code
Cases
- NodeTS-LeanCloud scaffold
- REST-Node-ts scaffold