Repository navigation
Description
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
We have a middleware service where we do add services that can be used dynamically by the developer during the application development like so:
@provide(App)
export class App extends AppExpress {
private middleware: IMiddleware;
private provider: IProvider;
constructor() {
super();
this.middleware = container.get<IMiddleware>(Middleware);
this.provider = container.get<IProvider>(Provider);
}
protected configureServices(): void {
this.middleware.addBodyParser();
this.middleware.setErrorHandler();
}
protected postServerInitialization(): void {
if (this.isDevelopment()) {
this.provider.envValidator.checkAll();
}
}
protected serverShutdown(): void {}
}The middleware are added in the middleware service as mentioned above as well as it's interfaces implemented here.
The interfaces are the options that can be optionally passed to the middleware.
This task has the objective of implementing the middleware express-rate-limit embedded in the ExpressoTS platform as the other middlewares.
More information here: https://github.com/express-rate-limit/express-rate-limit
Steps to reproduce
N/A
Expected behavior
Implemented express-rate-limit middleware and make it available as an option in the application provider class
Package version
2.2.1
Node.js version
18
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields✅ Done
Activity
devsargam commentedon Sep 30, 2023
@rsaz may I start working on this?? Can you please assign this to me?
rsaz commentedon Sep 30, 2023
Assigned to you. Good work! Looking forward to review your PR!
devsargam commentedon Oct 1, 2023
@rsaz I have implemented the required interface and added it in
middleware-service.ts.But can you pin point how can I test it?
rsaz commentedon Oct 1, 2023
In order for you test you have to build your library. Here are all the steps prior to the build:
1 - install the cli globally
2 - scaffold a project using the cli
3 - in the project dependencies of the app-test remove @expressots/core
4 - rename your .env.example in to .env only
5 -Now let's build the library with your changes
If everything goes right it will generate a
/libfolder container all lib code including your changes6 - Let's generate the package to test locally.
npm packwill generate.tgzpackage in which you can install in your app-test to replace the@expressots/corepackage you removed in the step 37 - it will be something like:
npm i expressots-core-2.3.0.tgzAfter done that just run
npm run devin your app-test application.Go in providers/application folder in the
application.provider.tsmentioned in the issue content right in the top.And in the section of configuring services you should be able to invoke your middleware for example:
The first test should be:
1 - if you dont have the rate limit package installed by the time you execute the application using
npm run devyou should throw a warning in the console saying, you should install the package for the rate limit middleware. Once you install, this warning should go away then you could use your middleware normally.2 - to really test your middleware working you should invoke any endpoint already created in the opinionated template. there is a folder user inside of useCases, and inside of this folder you will see several use cases such as create, delete, update and so on.
The controllers of each usecase are the entry points of each request.
Now is with you, any other doubt you might have you can query the documentatin, but with this information you already have 90% in your hand.
Happy coding and good studies.
rsaz commentedon Oct 1, 2023
Closed in the PR #115
Author: @devsargam
fix: fileupload req and res retrieval