Code Monkey home page Code Monkey logo

nest-middlewares's Issues

Morgan middleware fail to build on new project

node_modules/@nest-middlewares/morgan/index.d.ts:4:63 - error TS2314: Generic type 'Options<Request, Response>' requires 2 type argument(s).

4     static configure(format: string | morgan.FormatFn, opts?: morgan.Options): void;
                                                                ~~~~~~~~~~~~~~

node_modules/@nest-middlewares/morgan/index.d.ts:5:67 - error TS2314: Generic type 'Morgan<Request, Response>' requires 2 type argument(s).

5     static token(name: string, callback: morgan.TokenCallbackFn): morgan.Morgan;
                                                                    ~~~~~~~~~~~~~

npm install fails with 'ERESOLVE unable to resolve dependency tree'

Installing the middleware as per the documentation results in the below error.

Please also refer the attached logs.

npm install --save @nest-middlewares/helmet        

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: @nestjs/[email protected]
npm ERR! node_modules/@nestjs/common
npm ERR!   @nestjs/common@"^8.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @nestjs/common@"^6.0.0" from @nest-middlewares/[email protected]
npm ERR! node_modules/@nest-middlewares/helmet
npm ERR!   @nest-middlewares/helmet@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/abhilash.panickar/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/abhilash.panickar/.npm/_logs/2021-11-13T20_44_04_211Z-debug.log

2021-11-13T20_44_04_211Z-debug.log

eresolve-report.txt

如何使用它?

你好,能否写一个更详细的教程?能写个简单的例子最好。

problem in the docs

I know its small but someone (yours truly 🥇) didn't understand the ctrl+c crtl+v bug:

in the serve-static readme (and my guess its for all of them) you write
HelmetMiddleware.configure( /* options as per helmet docs */ )
HelmetMiddleware

change dependency to nest.js <= 9

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @nest-middlewares/[email protected] for the project I'm working on.

we are using nest.js 8, will soon switch to 9, so a dependency to v6 is not really useful, nor necessary: I forced install, and serve-favicon v6.0.1 works well with nest.js v8.4.7.

Here is the diff that solved my problem:

diff --git a/node_modules/@nest-middlewares/serve-favicon/package.json b/node_modules/@nest-middlewares/serve-favicon/package.json
index 4ea913c..7b50dd8 100644
--- a/node_modules/@nest-middlewares/serve-favicon/package.json
+++ b/node_modules/@nest-middlewares/serve-favicon/package.json
@@ -24,7 +24,7 @@
   },
   "homepage": "https://github.com/wbhob/nest-middlewares#readme",
   "peerDependencies": {
-    "@nestjs/common": "^6.0.0"
+    "@nestjs/common": "<9.0.0"
   },
   "dependencies": {
     "@types/express": "^4.16.0",

This issue body was partially generated by patch-package.

Errors update @nest-middleware/[email protected] to 7.0.1

Hello :)

Just to inform that on the last version of @nest-middlewares/[email protected] the are some errors due to way of importing things from dist folder inside node_modules.

  • Previously (version 6.0.0) helmet was added inside node modules trhough :
    import * as helmet from 'helmet';
  • Now each specific object is imported like this :
    import { ContentSecurityPolicyOptions } from "helmet/dist/types/middlewares/content-security-policy";

But there is a problem because nowthere is no "dist" folder in node_modules.
I don't know a solution for this because i'm not familiar with javascript modules and how to generate them in typescript.
But i think it's about the dependencies of nest-middleware/helmet ?

Here are the files that lead errors :
node_modules/@nest-middlewares/helmet/content-security-policy.d.ts:2
node_modules/@nest-middlewares/helmet/dns-prefetch-control.d.ts:2
node_modules/@nest-middlewares/helmet/expect-ct.d.ts:2
node_modules/@nest-middlewares/helmet/frameguard.d.ts:2
node_modules/@nest-middlewares/helmet/hsts.d.ts:2
node_modules/@nest-middlewares/helmet/referrer-policy.d.ts:2

Thanks in advance for your contributions to this package,
Have a great day,

Type Error Express-Bearer-Token

TypeScript Errors on the Config function claiming that that bearToken doesn't have the property Options. Apparently, bearerToken.BearerTokenOptions this does exist.

[express-session] Can't keep session values with default options.

In @nest-middlewares/express-session, always new session object is created per routing when options was applied.

if (ExpressSessionMiddleware.options) {
expressSession(ExpressSessionMiddleware.options)(req, res, next);

And express-session creates new instance of MemorySession if option.store wasn't specified.

https://github.com/expressjs/session/blob/10607bdb780204b91a8cf90e4ce27726619b8285/index.js#L99-L100

So the app can't keep values in the session.

I suspect the value of expressSession should be cached in the class ExpressSessionMiddleware.

Cors exception + Readme CopyPaste bug

CorsMiddleware.configure({})` 

This throws unhandled promise rejection exception.

Passing null instead seems to do the trick

CorsMiddleware.configure(null)` 

Also the Readme in CorsMiddleware uses HelmetMiddleware instead of CorsMiddleware. I assume this is a minor bug.

Is the MiddlewaresConsumer any different that MiddlewareConsumer (without s). Cause I couldnt find such class.

Examples / documentation

I desperately need some form of documentation on how to implement nest-middlewares/express-session but my Google-fu has failed me.

NestJs v6.0.0

Nest Js v6.0.0(nestjs/nest#1486) is in release candidate. I think few changes has occur for the middlewares.

Is there a plan to update to v6.0.0 packages in this repository ?

@nest-middlewares/helmet using the next major version of Helmet

I'm the maintainer of Helmet. I plan to release the next major version this Sunday, 2020-08-22.

Is there anything I can do to help get @nest-middlewares/helmet upgraded to helmet@4?

If you'd like to try out the release candidate now, you can install it with npm install helmet@next. If you'd rather discuss things outside of this issue, feel free to reach out to me another way.

Hope I can be helpful!

Dependency error with NestJS 10 when installing @nest-middlewares/morgan

Trying to install @nest-middlewares/morgan give the following dependency error.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @nest-middlewares/[email protected]
npm ERR! Found: @nestjs/[email protected]
npm ERR! node_modules/@nestjs/common
npm ERR!   @nestjs/common@"^10.0.0" from the root project
npm ERR!   peer @nestjs/common@"^10.0.0" from @nestjs/[email protected]
npm ERR!   node_modules/@nestjs/core
npm ERR!     @nestjs/core@"^10.0.0" from the root project
npm ERR!     peer @nestjs/core@"^10.0.0" from @nestjs/[email protected]
npm ERR!     node_modules/@nestjs/platform-express
npm ERR!       @nestjs/platform-express@"^10.0.0" from the root project
npm ERR!       2 more (@nestjs/core, @nestjs/testing)
npm ERR!     1 more (@nestjs/testing)
npm ERR!   2 more (@nestjs/platform-express, @nestjs/testing)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @nestjs/common@"^9.0.0" from @nest-middlewares/[email protected]
npm ERR! node_modules/@nest-middlewares/morgan
npm ERR!   @nest-middlewares/morgan@"^7.0.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @nestjs/[email protected]
npm ERR! node_modules/@nestjs/common
npm ERR!   peer @nestjs/common@"^9.0.0" from @nest-middlewares/[email protected]
npm ERR!   node_modules/@nest-middlewares/morgan
npm ERR!     @nest-middlewares/morgan@"^7.0.1" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

In CorsMiddleware, Type 'RequestHandler' is not assignable to type 'Promise<MiddlewareFunction<any, any, any>>'

Thanks for this collection, it looks really helpful!

While using [email protected] with nestjs/[email protected], [email protected] and I encountered the following error:

node_modules/@nest-middlewares/cors/index.d.ts(7,5): error TS2416: Property 'resolve' in type 'CorsMiddleware' is not assignable to the same property in base type 'NestMiddleware'.
  Type '(...args: any[]) => RequestHandler' is not assignable to type '(...args: any[]) => MiddlewareFunction<any, any, any> | Promise<MiddlewareFunction<any, any, any>>'.
    Type 'RequestHandler' is not assignable to type 'MiddlewareFunction<any, any, any> | Promise<MiddlewareFunction<any, any, any>>'.
      Type 'RequestHandler' is not assignable to type 'Promise<MiddlewareFunction<any, any, any>>'.
        Property 'finally' is missing in type 'RequestHandler'.

Edit: Just make resolve return an ExpressMiddleware and it works fine, i.e:

@Injectable()
export class CorsMiddleware implements NestMiddleware {

  public static configure(opts: cors.CorsOptions) {
    this.options = opts;
  }

  private static options: cors.CorsOptions;

  public resolve(...args: any[]): ExpressMiddleware {
    if (CorsMiddleware.options) {
      return cors(CorsMiddleware.options);
    }

    return cors();
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.