mirror of
https://gitlab.silvrtree.co.uk/martind2000/censis-obrand.git
synced 2025-02-14 06:39:18 +00:00
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
|
/*jshint node:true*/
|
||
|
var util = require('util');
|
||
|
|
||
|
module.exports = function(app) {
|
||
|
var express = require('express');
|
||
|
var pagesRouter = express.Router();
|
||
|
|
||
|
pagesRouter.get('/', function(req, res) {
|
||
|
res.send({
|
||
|
'pages': []
|
||
|
});
|
||
|
});
|
||
|
|
||
|
pagesRouter.post('/', function(req, res) {
|
||
|
console.log(util.inspect(req.body.data));
|
||
|
res.status(201).end();
|
||
|
});
|
||
|
|
||
|
pagesRouter.get('/:id', function(req, res) {
|
||
|
res.send({
|
||
|
'pages': {
|
||
|
id: req.params.id
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
pagesRouter.put('/:id', function(req, res) {
|
||
|
res.send({
|
||
|
'pages': {
|
||
|
id: req.params.id
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
pagesRouter.delete('/:id', function(req, res) {
|
||
|
res.status(204).end();
|
||
|
});
|
||
|
|
||
|
// The POST and PUT call will not contain a request body
|
||
|
// because the body-parser is not included by default.
|
||
|
// To use req.body, run:
|
||
|
|
||
|
// npm install --save-dev body-parser
|
||
|
app.use('/api/pages', require('body-parser').json({type: 'application/vnd.api+json'}));
|
||
|
|
||
|
// After installing, you need to `use` the body-parser for
|
||
|
// this mock uncommenting the following line:
|
||
|
//
|
||
|
//app.use('/api/pages', require('body-parser').json());
|
||
|
app.use('/api/pages', pagesRouter);
|
||
|
};
|