1.0.8 • Published 6 years ago
express-function v1.0.8
Express Function as Service Middleware
Usage
Load functions:
app.use(func(main, [hello], '/functions')).listen(80);
request by GET/POST:
request.post('localhost:80')
.send({action:'hello'})
.then(response => {
console.log(response.text)
})
Example (One function)
const func = require('express-function')
app.use(func(main)).listen(80);
function main() {
return `ok`
}
GET localhost ok
Example (Multiple functions)
const func = require('express-function')
app.use(func(main, hello)).listen(80)
async function main() {
return `ok`
}
async function hello() {
return `world`
}
GET localhost?action=hello word
Example (File functions)
/index.js
const func = require('express-function')
app.use(func('/functions')).listen(80)
/functions/foo.js
async function foo() {
return `bar`
}
GET localhost?action=foo bar