-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (22 loc) · 695 Bytes
/
index.js
File metadata and controls
28 lines (22 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const express = require("express");
const rateLimit = require("express-rate-limit");
class StartServer {
static listen(port, options = {}) {
const app = express();
if (options.rateLimit) {
const limiter = rateLimit({
windowMs: options.rateLimit.windowMs || 60000,
max: options.rateLimit.max || 100
});
app.use(limiter);
}
app.use(express.json());
app.get("/", (req, res) => {
res.send("Server is running!");
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
}
}
module.exports = StartServer;