-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
41 lines (32 loc) · 884 Bytes
/
server.js
File metadata and controls
41 lines (32 loc) · 884 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
29
30
31
32
33
34
35
36
37
38
39
40
41
import express from "express";
import "dotenv/config";
const app = express();
import fileUpload from "express-fileupload";
import helmet from "helmet";
import cors from "cors";
import { limiter } from "./config/ratelimiter.js";
import logger from "./config/logger.js";
const PORT = process.env.PORT || 4000;
// Middleware
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(express.static("public"));
app.use(fileUpload());
app.use(helmet());
app.use(cors());
app.use(limiter);
app.get("/", (req, res) => {
return res.json({
message: "Hello It's working...",
});
});
// Import routes
import ApiRoutes from "./routes/api.js";
app.use("/api/v1", ApiRoutes);
// Logger
// logger.info("Application is running...");
/* Jobs Import */
import "./jobs/index.js";
app.listen(PORT, () => {
console.log(`Server is running on PORT ${PORT}`);
});