-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
37 lines (25 loc) · 826 Bytes
/
app.js
File metadata and controls
37 lines (25 loc) · 826 Bytes
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 express = require("express");
const morgan = require("morgan");
const cors = require("cors");
const recipeRouter = require("./routes/recipe.route");
const userRouter = require("./routes/user.route");
const { pageNotFound, serverNotFound } = require("./middlewares/handleErrors");
require('dotenv').config();
require('./config/db');
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(morgan("dev"));
// app.use(cors({origin:'http:// localhost:4200'}));
app.use(cors());
app.get('/', (req, res) => {
res.send("wellcome");
});
app.use("/recipes", recipeRouter);
app.use("/users", userRouter);
app.use(pageNotFound);
app.use(serverNotFound);
const port = process.env.PORT;
app.listen(port, () => {
console.log("running at http://localhost:" + port);
});