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

Is there support for export? #132

Open
Khuzha opened this issue Sep 21, 2021 · 2 comments
Open

Is there support for export? #132

Khuzha opened this issue Sep 21, 2021 · 2 comments

Comments

@Khuzha
Copy link

Khuzha commented Sep 21, 2021

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?

@Cody2333
Copy link
Owner

how do you run the script?

@Cody2333
Copy link
Owner

you may need ts-node to run the script,
or you need to exec tsc to compile your ts code first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants