Package Exports
- methor
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (methor) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
methor
a router style restserver - method
Install
$ npm install methor --saveUSAGE
'use strict'
const Methor = require('methor')
const path = require('path')
const user = {
login: require('./methods/login'),
logout: require('./methods/logout'),
}
const methor = new Methor({
port: 3004,
methods: {
user
},
services: {
User: {
login(username, pwd) {
return // check
}
}
},
funcs: {
this_is_a_func(){}
},
routes: [{
path: '/test',
router(req, res) {
return {
ahihi: true
}
},
children: [{
path: '/test1',
method: 'POST',
router() {
this.this_is_a_func()
return 'xin chao'
}
}]
}],
created({port, router}) {
console.log('app started at port %d', port)
router.get('/logout', (req, res) => {
res.end('ahihi do ngok')
})
}
})
.$on('request', (req, res) => {
console.log('request coming')
})
.get('/', (req, res) => {
res.end(':D')
})
// curl http://localhost:3004/restserver?method=user.login
Methor(options)
return Abstract of http.Server
Options