Skip to content

Instantly share code, notes, and snippets.

@fabiogoll
Last active October 10, 2016 19:07
Show Gist options
  • Save fabiogoll/87ddac67d97c75d04ea021de3f28d13d to your computer and use it in GitHub Desktop.
Save fabiogoll/87ddac67d97c75d04ea021de3f28d13d to your computer and use it in GitHub Desktop.
Service agnostico

Project

  • shared
  • web
  • mobile
{
"name": "my-shared",
"version": "1.0.0",
"description": "Shared mobile/web",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Fábio Goll",
"license": "MIT",
"dependencies": {
"axios": "^0.14.0"
}
}
var axios = require('axios')
var UserService = function() {
this.getUsers = function() {
return axios.get('/users')
}
}
module.exports = new UserService()
"dependencies": {
...
"my-shared": "file:../shared"
},
var UserService = require('my-shared/services/UserService')
UserService.getUsers().then( ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment