-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (19 loc) · 683 Bytes
/
Copy pathindex.js
File metadata and controls
25 lines (19 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
import express from 'express';
import dotenv from 'dotenv';
import cors from 'cors';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import connectdb from './connectdb.js';
import userRoutes from './routes/userRoutes.js';
import blogRoutes from './routes/blogRoutes.js';
dotenv.config();
const app = express();
connectdb();
app.use(cors());
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));
const PORT = 8000;
//api redirecting to /routes directory for each type of request
app.use("/api/user",userRoutes);
app.use("/api/blogs",blogRoutes);
app.listen(PORT, () => console.log(`Server is running successfully on PORT ${PORT}`));