-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.js
More file actions
34 lines (22 loc) · 791 Bytes
/
notes.js
File metadata and controls
34 lines (22 loc) · 791 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
const dotenv = require('dotenv');
dotenv.config();
var express = require('express');
var app = express();
var fs = require('fs');
const db = require('./queries.js');
var bodyParser = require('body-parser')
app.use( bodyParser.json() ); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
extended: true
}));
//paths
app.get('/listNotes',db.getNotes);
app.post('/postNote',db.postNote);
app.delete('/deleteNote',db.deleteNote);
app.post('/updateNote',db.updateNote);
app.post('/fetchNote',db.fetchNote);
var server = app.listen(process.env.PORT,function(){
var host = server.address().address;
var port = server.address().port;
console.log("Notes app listening at http://%s:%s", process.env.HOST, port);
})