-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.ts
More file actions
44 lines (31 loc) · 1.29 KB
/
server.ts
File metadata and controls
44 lines (31 loc) · 1.29 KB
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
// import express from "express";
let express = require("express");
const app = express();
const port = 2000;
import home from "./routeImplementation/home";
import getAllRecords from "./routeImplementation/getAllRecords";
import getRecordById from "./routeImplementation/getRecordById";
import addRecord from "./routeImplementation/addRecord";
import updateRecord from "./routeImplementation/updateRecord";
import deleteById from "./routeImplementation/deleteRecordById";
const bodyParser = require("body-parser");
app.use(bodyParser.json());
import addDataValidation from "./validation/data.validation";
import updateByPatch from "./routeImplementation/updateUsingPatch";
app.get("/", home);
app.get("/datasets/get", getAllRecords);
app.get("/datasets/getrecord/:id", getRecordById);
app.post("/datasets/create",addDataValidation, addRecord);
app.put("/datasets/update/:id",addDataValidation, updateRecord);
app.delete("/datasets/delete/:id", deleteById);
app.patch("/datasets/partialupdate/:id",addDataValidation,updateByPatch)
//IF USER WILLINGLY CHANGES PATH
app.all("*", (req: any, res: any) => {
res.status(404).send("404! Page not found");
});
app.listen(port, () => {
console.log("changes are done!");
console.log(`server running in port ${port}!`);
});
// database1.connect();
export default app;