1.0.8 • Published 5 years ago

express-function v1.0.8

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

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

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago