serverless-tools

Serverless toolbox

Showing:

Popularity

Downloads/wk

1

GitHub Stars

1

Maintenance

Last Commit

3yrs ago

Contributors

3

Package

Dependencies

10

License

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Serverless Toolboxs

Serverless License NPM Build Status Coverage Status Greenkeeper badge

Serverless toolbox

Install

npm i serverless-tools

Examples

httpless

A more node-style way to write your handler functions.

const httpless = require('serverless-tools/httpless')

exports.hello = httpless((req, res) => {
    res.setHeader('Content-Type', 'text/plain')
    res.end(`Hello ${req.query.name || 'gays'}! -- Provide by ${req.provider}`)
})

{
    statusCode: 200,
    headers: {
        'content-type': 'text/plain'
    },
    body: 'Hello gays! -- Provide by aws'
}

microless

A micro-style way to write your handler functions.

const microless = require('serverless-tools/microless')
const { json, send, sendError, createError } = microless

exports.hello = microless(() => {
    return 'Hello world'
})

exports.ok = microless((req, res) => {
    send(res, 200, { message: 'ok' })
})

exports.auth = microless((req, res) => {
    if (!auth(req)) throw createError(401, 'Must signin first')
    send(res, 200, 'welcome')
})

exports.download = microless((req, res) => {
    if (limited) {
        const err = new Error('Bandwidth limit exceeded')
        err.status = 509
        err.expose = true
        sendError(req, res, err)
        return
    }

    send(res, 200, base64Content)
})

probe

Generate a report for serverless function runtime environment.

const probe = require('serverless-tools/probe')

console.log(probe())

{
    os: { },
    process: {
        env: { },
    },
    'aws-sdk': { },
}

evaluate

Evaluate runtime feature and guess possible env.

const evaluate = require('serverless-tools/evaluate')

console.log(evaluate())

{
    provider: 'aws',
    nodeEnv: 'production'
}

Write evaluate envs into process.env. This side effect happend immediately.

require('serverless-tools/setEnv')

console.log(process.env)

{
    ...
    PROVIDER: 'aws',
    NODE_ENV: 'production',
    ...
}

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100