-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
56 lines (39 loc) · 1.68 KB
/
server.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require('newrelic');
require('dotenv').config();
//calling all the required files
var express = require("express");
path = require('path');
db = require("./routes/db.js");
boards = require("./routes/boards.js");
columns = require("./routes/columns.js");
notes = require("./routes/notes.js");
var port = 3000;
var app = express();
app.configure(function () {
app.set('port', process.env.PORT || port);
app.use(express.logger('dev')); /* 'default', 'short', 'tiny', 'dev' */
app.use(express.bodyParser());
app.use(express.static(path.join(__dirname, 'public')));
});
const connectionString = process.env.DB_CONNECTION_STRING;
db.connectToDatabase(connectionString);
//boards
app.get('/boards', boards.findAll);
app.get('/boards/:boardId', boards.findById);
app.post('/boards/',boards.addBoard);
app.put('/boards/:boardId',boards.updateBoard);
app.delete('/boards/:boardId', boards.deleteBoard);
//columns
app.get('/boards/:boardId/columns', columns.findAll);
app.get('/boards/:boardId/columns/:columnId', columns.findById);
app.post('/boards/:boardId/columns',columns.addColumn);
app.put('/boards/:boardId/columns/:columnId',columns.updateColumn);
app.delete('/boards/:boardId/columns/:columnId', columns.deleteColumn);
//notes
app.get('/boards/:boardId/columns/:columnId/notes', notes.findAll);
app.get('/boards/:boardId/columns/:columnId/notes/:noteId', notes.findById);
app.post('/boards/:boardId/columns/:columnId/notes',notes.addNote);
app.put('/boards/:boardId/columns/:columnId/notes/:noteId',notes.updateNote);
app.delete('/boards/:boardId/columns/:columnId/notes/:noteId', notes.deleteNote);
app.listen(process.env.PORT || 3000);
console.log("Listening on port " + port);