-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (30 loc) · 940 Bytes
/
app.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
import express from "express";
import cors from "cors";
import dotenv from "dotenv";
import login from "./Routes/User_Operations/Login.js";
import register from "./Routes/User_Operations/Register.js";
import logout from "./Routes/User_Operations/Logout.js";
import { auth, state } from "./Routes/Guard/guard.js";
import cookieParser from "cookie-parser";
import mongoose from "mongoose";
dotenv.config();
const app = express();
app.use(express.json());
app.use(cookieParser());
app.use(cors({credentials: true, origin: true}));
app.use("/api/login", state, login);
app.use("/api/register", state, register);
app.use("/api/logout", auth, logout);
mongoose
.connect(process.env.MONGO_URL, {
useunifiedTopology: true,
useNewUrlParser: true,
})
.then(() => {
app.listen(process.env.PORT || 5000, () => {
console.log("Server Çalııyor...");
});
})
.catch(() => {
return console.log("db error");
});