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

Improve swagger integration #507

Closed
gperdomor opened this issue Oct 6, 2020 · 11 comments
Closed

Improve swagger integration #507

gperdomor opened this issue Oct 6, 2020 · 11 comments

Comments

@gperdomor
Copy link

Hi... First of all, great job...

Can you provide a way to configure swagger integration and avoid this?... The ideal is having a way to customize the api tag

Screen Shot 2020-10-05 at 11 55 55 PM

@willsoto
Copy link
Owner

willsoto commented Oct 6, 2020

What is your preferred fix for this? Would you like the ability to hide the endpoint from swagger? Just give it a name?

@gperdomor
Copy link
Author

Mmm... Now that you mention, both options are valid, is possible use both for more flexibility? maybe we can hide or show based on production/dev mode

@willsoto
Copy link
Owner

willsoto commented Oct 6, 2020

The best way to solve this problem from my point of view is to give you a way to provide a custom controller where you can do whatever annotations you want. This module shouldn't have any knowledge of Swagger. If this would work for you, let me know and I will see if I can come up with a solution.

@gperdomor
Copy link
Author

@willsoto yes, that will work too... Maybe that controller should implement some kind of interface provided by you, or extends your base controller or something like that to guarantee that the proper prom-client method is invoked

@willsoto
Copy link
Owner

willsoto commented Oct 9, 2020

Released as v1.1.0. Here are the docs. Let me know if you have any issues.

@gperdomor
Copy link
Author

@willsoto Thanks 🙌...

@gperdomor
Copy link
Author

@willsoto I got this error with 1.0.0 and 1.1.0 but with 0.1.3 works fine

Debugger listening on ws://localhost:51027/378b1f27-b3af-412b-b51f-dcd1942e4a1b
Debugger listening on ws://localhost:51028/378b1f27-b3af-412b-b51f-dcd1942e4a1b
For help, see: https://nodejs.org/en/docs/inspector
/Users/gperdomor/Developer/client/alliotek/node_modules/@willsoto/nestjs-prometheus/dist/esm.js:1
import { Get, Res, Controller, Inject, Module } from '@nestjs/common';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:791:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.@willsoto/nestjs-prometheus (/Users/gperdomor/Developer/client/alliotek/dist/apps/service-broadcaster/webpack:/external "@willsoto/nestjs-prometheus":1:1)
    at __webpack_require__ (/Users/gperdomor/Developer/client/alliotek/dist/apps/service-broadcaster/webpack:/webpack/bootstrap:19:1)
    at Module../apps/service-broadcaster/src/app/app.module.ts (/Users/gperdomor/Developer/client/alliotek/dist/apps/service-broadcaster/main.js:105:85)
No type errors found
Version: typescript 4.0.3
Time: 5503ms

@willsoto
Copy link
Owner

willsoto commented Oct 9, 2020

Looks like you are trying to load the esm version, I've specified the entrypoints here. I use exports since that is what I understood to be the forward compatible way of declaring esm.

Can you remove the exports key from package.json (here) and try bundling again please?

@willsoto
Copy link
Owner

willsoto commented Oct 9, 2020

In the meantime, I've cut a v2.0.0 that only includes the commonjs version, so you should no longer see this issue.

@gperdomor
Copy link
Author

gperdomor commented Oct 9, 2020

@willsoto yes, removing "exports": "./dist/esm.js" from package.json in v1.1.0 solves the problem

@willsoto
Copy link
Owner

willsoto commented Oct 9, 2020

Thanks. You can upgrade to v2.0.0 and the issue will be resolved then.

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