-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
38 lines (32 loc) · 1.39 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
// Create the database
// var PouchDB = require('pouchdb');
// var db = new PouchDB('workshop');
// =========================
// App Configs
// =========================
// app.use(express.static(__dirname + '/public'));
// app.use(bodyParser.urlencoded({ extended: true }));
// app.use(logger('dev'));
// app.disable('x-powered-by');
// Allowing CORS
// app.use(function(req,res,next) {
// res.append('Access-Control-Allow-Origin', req.headers.origin || '*');
// res.append('Access-Control-Allow-Credentials', 'true');
// res.append('Access-Control-Allow-Methods', ['GET', 'OPTIONS', 'PUT', 'POST', 'DELETE']);
// res.append('Access-Control-Allow-Headers',
// 'Origin, X-Requested-With, Content-Type, Accept');
// next();
// });
// app.enable('trust proxy');
// =======================================================================
// RESTful Routes
// HTTP Verbs: GET, POST, PUT, DELETE
//
// Name | Path | HTTP Verb | Purpose
// =======================================================================
// Index | / | GET | List all the posts
// Create | / | POST | Create a new post
// Show | /:id | GET | Show a single post
// Update | /:id | PUT | Update a particular post
// Delete | /:id | DELETE | Delete a particular post
// =======================================================================