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
@nanoexpress/middleware-schemator esModule import on cjs #24
Comments
Closed on #23 |
This seems to break on debian (linux),
As |
i think because i'm using dynamic import when importing the module the return from import was a promise, i try fix the error using Promise chain like
not throwing the error, but still i got no response with dist directory before i'm make this change. Maybe i'll rollback this commit later if still not return, but the cjs method will waiting another fix, because import path not compatible. |
Yeah, noticed that it was a promised. Promise chain or maybe async/await? Please tag me if you want me to test on a linux installation or such :) |
Before this change, staticServe import was from nanoexpress: ^4.0.0 |
I'm using
Swagger loads for me on |
Try using that version version dependencies, got an error
using example code import bodyParser from '@nanoexpress/middleware-body-parser';
import schemator from '@nanoexpress/middleware-schemator';
import nanoexpress from 'nanoexpress';
import path from 'path';
const app = nanoexpress({
jsonSpaces: 2
});
const schematorInstance = schemator({ swaggerPath: path.resolve('./swagger.json') });
app.define(schematorInstance.define);
app.use(bodyParser());
app.get(
'/',
// Here any body-parser, form-data logic (all preprocess middlewares)
schematorInstance.load({ method: 'get', attach: '/', path: path.resolve('./docs.yml') }),
async () => ({ status: 'success' })
);
app.post(
'/',
// Here any body-parser, form-data logic (all preprocess middlewares)
schematorInstance.load({ method: 'post', attach: '/', path: path.resolve('./docs.yml') }),
async (req) => ({ status: 'success', data: req.body })
);
app.listen(4000); |
already test using windows and docker toolbox still got an error like above, can you share your code ? if still not working using your code will try your env for testing @torbjorn-kvist |
Strange, tried to clear all my local cache and removed It seems that config does not exist in the scope of the middlewares/packages/schemator/methods/render.js Lines 16 to 20 in 9bc598d
Which seems kinda strange, somehow the config does not exist in the scope anymore but works if I add
|
Yeah, already tried with adding and after a while, tried refresh and see what holding the content show, the swagger file always pending without a timeout |
i found the problem for not showing content if switched to live mode, filepath got an double directory and return not found, but the catch was set to null so the middleware think error not happen. I don't know this only happen on windows or not, can you check it ? @torbjorn-kvist url: /swagger-ui-dist/swagger-ui-standalone-preset.js
filePath: D:\febryan\nanoexpress-middleware\packages\schemator\examples\node_modules\swagger-ui-dist/swagger-ui-dist/swagger-ui-standalone-preset.js
stat.error: [Error: ENOENT: no such file or directory, stat 'D:\febryan\nanoexpress-middleware\packages\schemator\examples\node_modules\swagger-ui-dist\swagger-ui-dist\swagger-ui-standalone-preset.js'] {
errno: -4058,
code: 'ENOENT',
syscall: 'stat',
path: 'D:\\febryan\\nanoexpress-middleware\\packages\\schemator\\examples\\node_modules\\swagger-ui-dist\\swagger-ui-dist\\swagger-ui-standalone-preset.js'
} edit: |
Bug Report
Is you/your team sponsoring this project
If your team sponsoring this project, please attach here your team lead or who purchased license GitHub login
Minimal reproducible repo
https://github.com/nanoexpress/middlewares/tree/master/packages/schemator
Current Behavior
const schemator = require('@nanoexpress/middleware-schemator/cjs');
got an error message:
Expected behavior/code
not getting error exception ERR_REQUIRE_ESM.
Environment
Possible Solution
Pull Request #23
Additional context/Screenshots
Note
The text was updated successfully, but these errors were encountered: