koa-swagger-decorator
koa-swagger-decorator copied to clipboard
Is there support for export?
Hello! I'm trying to set up your module and have some troubles.
I made such file for generating swagger.json without starting app (from docs):
import path from 'path';
import { SwaggerRouter } from 'koa-swagger-decorator'
const __dirname = path.resolve();
// init router
const router = new SwaggerRouter();
// load controllers
router.mapDir(path.resolve(__dirname, './controllers'));
// dump swagger json
router.dumpSwaggerJson({
filename: 'swagger.json', // default is swagger.json
dir: process.cwd(), // default is process.cwd()
});
And when I run it, I get an error:
export { default as AuthController } from './includes/AuthController';
^^^^^^
SyntaxError: Unexpected token 'export'
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at loadModule (/opt/projects/asudr/backend/node_modules/koa-swagger-decorator/dist/utils.js:45:17)
at loadClass (/opt/projects/asudr/backend/node_modules/koa-swagger-decorator/dist/utils.js:54:17)
How can I resolve it?
how do you run the script?
you may need ts-node to run the script,
or you need to exec tsc
to compile your ts code first