Last active
August 29, 2015 14:21
-
-
Save A/08ae53dfd876e1aaa1f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('superagent'); // you know… | |
const mock = require('superagent-crud-mock'); // my awesome mock module | |
const topics = require('./topics'); // service provider, for example it's localstorage | |
mock(superagent) // patch `superagent` | |
.get('/topics/', (req, res) => { | |
res.json(topics.get()); // send json with data taken from the service | |
}) | |
.get('/topics/:id', (req, res) => { | |
res.json(topics.get(req.params.id)); | |
}) | |
.post('/topics/:id', (req, res) => { | |
res.json(topics.create(data)); | |
}) | |
.put('/topics/:id', (req, res) => { | |
res.json(topics.update(ctx.data)); | |
}) | |
.del('topics/:id', (req, res) => { | |
res.json(topics.del(ctx.data)) | |
}) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment