-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
55 lines (41 loc) · 1.37 KB
/
server.js
File metadata and controls
55 lines (41 loc) · 1.37 KB
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
53
54
55
////////////////////////////
// SETUP and CONFIGURATION
/////////////////////////////
var express = require('express'),
bodyParser = require('body-parser'),
app = express(),
controllers = require('./controllers');
////////////////////////////
// MIDDLEWARE
/////////////////////////////
app.use(express.static('public'));
app.use(bodyParser.urlencoded({ extended: true }));
var db = require('./models');
////////////////////
// ROUTES
///////////////////
// root route
app.get('/', function (req, res) { res.sendFile('views/index.html' , { root : __dirname}); });
// routes us to endpoint info
app.get('/api', controllers.api.index);
//get all events
app.get('/api/events', controllers.events.index);
//search through keywords
app.get('/api/searchKeyword', controllers.events.searchKeyword);
//search by date
app.get('/api/searchDate', controllers.events.searchDate);
//get one event by specified parameters
app.get('/api/events/:id', controllers.events.show);
// create an event
app.post('/api/events', controllers.events.create);
//update one event
app.put('/api/events/:id', controllers.events.update);
//delete one event
app.delete('/api/events/:id', controllers.events.destroy);
////////////////////
// SERVER LISTENER
///////////////////
app.set('port', (process.env.PORT || 3000));
app.listen(app.get('port'), function() {
console.log('TECHSPACE ON 3K!');
});