-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServer.js
29 lines (23 loc) · 847 Bytes
/
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
require('dotenv').config({ path: `${process.cwd()}/.env` });
const express = require("express");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const cors = require("cors");
const catchAsync = require('./utils/catchAsync');
const AppError = require('./utils/appError');
const app = express();
app.use(cors());
app.use(express.json({ limit: '50mb' }));
const AuthRouter = require("./Routes/AuthRoute");
app.use("/User", AuthRouter);
const productRouter = require("./Routes/product");
app.use("/products", productRouter);
app.use(bodyParser.json());
app.use(
'*',
catchAsync(async (req, res, next) => {
throw new AppError(`Can't find ${req.originalUrl} on this server`, 404);
})
);
const PORT = process.env.PORT || 8000 ;
app.listen(PORT,()=> console.log(`Server running on PORT ${PORT}`))