-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
22 lines (20 loc) · 747 Bytes
/
server.js
File metadata and controls
22 lines (20 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const express = require('express')
const mongoose = require('mongoose')
const bodyParser = require('body-parser');
const Note = require('./src/models/Note');
const route = require('./src/routes/Note');
const app = express()
const dotenv = require('dotenv')
dotenv.config()
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
//'mongodb+srv://jainkunal129:ls9hzGAy1hTqvMAX@cluster0.u4jilpn.mongodb.net/?retryWrites=true&w=majority'
mongoose.connect(process.env.SYS_URL).then(() => {
app.listen(process.env.SYS_PORT || 3000)
//Home Route
app.get('/', (req, res) => {
const response = { message: "API Works!" };
res.json(response);
})
app.use('/notes', route)
})