Skip to content

Instantly share code, notes, and snippets.

@elimence
Created January 27, 2017 20:54
Show Gist options
  • Save elimence/f179656b8a7a7db7c1fb5b0ae251f351 to your computer and use it in GitHub Desktop.
Save elimence/f179656b8a7a7db7c1fb5b0ae251f351 to your computer and use it in GitHub Desktop.
class WillService {
constructor (options) {
this.willData = options.willData
}
getWill (willId) {
return this.willData.getWill(willId)
}
createWill (data) {
return this.willData.create(data) // { title: 'my first will', content: '' }
}
}
function createWillService (options) {
return new WillService(options)
}
export createWillService
/////////////////////////////////////////////
import createWillService from 'will-service'
const options = {
willData: {}
}
const WillService = createWillService(options)
app.get('/wills/{id}', WillService.getWill(req.params.id))
app.post('/wills', WillService.createWill(req.body))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment