-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
37 lines (34 loc) · 1.11 KB
/
server.js
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
const signinUser = require("./auth/sign_in");
const signupUser = require("./auth/sign_up");
const getUserData = require("./auth/getUser_data");
const deleteUser = require("./auth/delete_user");
const updateUser = require("./auth/update_user");
const express = require("express");
const bodyParser = require("body-parser");
const mongoose = require("mongoose");
const app = express();
app.use(bodyParser.json());
const dbUrl =
//mongodb+srv://mouhibm777:[email protected]/?retryWrites=true&w=majority&appName=Cluster0
"";
mongoose
.connect(dbUrl, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("MongoDB connected");
})
.catch((err) => {
console.error("MongoDB connection error:", err);
process.exit(1);
});
app.post("/api/v1/signin", signinUser);
app.post("/api/v1/signup", signupUser);
app.get("/api/v1/user_data", getUserData);
app.delete("/api/v1/users/:id", deleteUser);
app.put("/api/v1/updateUser", updateUser);
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});