-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
44 lines (35 loc) · 1.18 KB
/
app.ts
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
42
43
44
"use strict";
require("dotenv").config();
const express = require("express");
const app = express();
const cors = require("cors");
const fileUpload = require("express-fileupload");
const path = require("path");
const { errorHandler } = require("./middleware/errorMiddleware");
const connectDB = require("./config/db");
const port = process.env.PORT || 3001;
import gradeRoute from "./routes/gradeRoute";
import textRoute from "./routes/textRoute";
import uploadRoute from "./routes/uploadRoute";
import userRoute from "./routes/userRoute";
import markRoute from "./routes/markRoute";
import allUploadsRoute from "./routes/allUploadsRoute";
connectDB();
app.use(fileUpload());
app.use(cors());
// app.use(errorHandler);
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", ["*"]);
next();
});
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use("/api/texts", textRoute);
app.use("/api/viewGrade", gradeRoute);
app.use("/api/uploads", uploadRoute);
app.use("/api/users", userRoute);
app.use("/api/mark", markRoute);
app.use("/api/all-uploads", allUploadsRoute);
app.listen(port, () => {
console.log(`Server is started on port ${port}`);
});