-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
39 lines (38 loc) · 1.07 KB
/
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
34
35
36
37
38
39
const express = require("express");
const dotenv = require("dotenv");
const mongoose = require("mongoose");
// const AppError=require('./utils/AppError')
// const globleErrorHandler=require('./controllars/errorControllar')
const ScholarshipRoute = require("./routes/ScholarshipRout");
// const userRoute = require("./routes/userroute");
dotenv.config({
path: "./config.env",
});
const DB = process.env.DATA_BASE.replace(
"PASSWORD",
process.env.DATA_BASE_PASSWORD
);
mongoose
.connect(DB, {
useNewUrlParser: true,
// useCreateIndex: true,
// useFindAndModify: true,
useUnifiedTopology: true,
})
.then((con) => {
console.log("success conection");
});
const app = express();
app.use(express.json());
app.use("/api/v1/Scholarships", ScholarshipRoute);
// app.use("/api/v1/user", userRoute);
app.all('*',(req,res,next)=>{
// next(new AppError(`can't find ${req.originalUrl} on the server`,404));
res.status(404).json({
result:"fail",
messege:`can't find ${req.originalUrl} on the server`
})
})
// app.use(globleErrorHandler)
module.exports = app;
//