We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 3a921b5 + 8dff7f5 commit 197d848Copy full SHA for 197d848
index.js
@@ -1,18 +1,24 @@
1
constexpress=require("express");
2
+constrateLimit=require("express-rate-limit");
3
4
classStartServer{
-staticlisten(port){
5
+staticlisten(port,options={}){
6
constapp=express();
7
-// Middleware (optional)
8
+if(options.rateLimit){
9
+constlimiter=rateLimit({
10
+windowMs: options.rateLimit.windowMs||60000,
11
+max: options.rateLimit.max||100
12
+});
13
+app.use(limiter);
14
+}
15
+
16
app.use(express.json());
17
-// Default route (optional)
18
app.get("/",(req,res)=>{
19
res.send("Server is running!");
20
});
21
-// Start the server and log the default message
22
app.listen(port,()=>{
23
console.log(`Server is running on port ${port}`);
24
0 commit comments