-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathapp.js
50 lines (30 loc) · 1.04 KB
/
app.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
var express = require('express');
var bodyParser = require('body-parser');
var cors = require('cors');
var database = require('./app/lib/database');
var taskController = require('./app/task/taskController');
// Defining variables
var SERVER_PORT = 5000;
var app = express();
// applying middlewares
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(cors());
// create Task
app.post('/api/v1.0/task',taskController.createTask);
// Get all task resource
app.get('/api/v1.0/task',taskController.getTask);
// Get task by id
app.get('/api/v1.0/task/id/:taskId',taskController.getTaskById);
// Delete task by id
app.delete('/api/v1.0/task/id/:taskId',taskController.deleteTaskById);
// Update task status by id
app.put('/api/v1.0/task/id/:taskId',taskController.updateTaskById);
// this wrapper is only for testing purpose
if(!module.parent){
// staring the express server
app.listen(SERVER_PORT,function(){
console.log("Server is listening at port : ",SERVER_PORT);
});
}
module.exports = app;