forked from EarlyTalent/node_backend_sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (24 loc) · 683 Bytes
/
Copy pathindex.js
File metadata and controls
35 lines (24 loc) · 683 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
// NPM Packages
const express = require('express')
const dotenv = require("dotenv");
const cors = require('cors')
// DB Connection
const connectDB = require ('./db')
// Import Routes
const blogRouter = require('./routes/blogRoutes')
const commentRouter = require('./routes/commentRoutes')
// ENV Config
dotenv.config({ path: ".env" });
// Express Config
const app = express()
const port = 3001
app.use(express.urlencoded({ extended: true }))
app.use(cors())
app.use(express.json())
// Use DB Connection
connectDB()
// Use Routes
app.use('/api', blogRouter)
app.use('/api/comments', commentRouter)
// Run App
app.listen(port, () => console.log(`Server running on ${port}`))