Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tote-lib

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tote-lib

`tote-lib` is a helper library for [Tote](https://github.com/alizahid/tote).

  • 0.0.8
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

tote-lib

tote-lib is a helper library for Tote.

API

tote-lib exports three items.

Func

Func is the class you use to setup your function. It includes several helper methods.

Example
// import dependencies
import { Func, joi } from 'tote-lib'

// create your function
class Hello extends Func {
  // define your schema
  schema = {
    // query parameters
    query: joi.object({
      number: joi.number()
    })
  }

  // define your function here
  invoke() {
    // get query params
    const {
      query: { number = 5 }
    } = this.request

    // return object
    return {
      hello: 'world',
      result: number * 2
    }
  }
}

// bootstrap and export
export default Func.bootstrap(Hello)
Options
NameTypeDescription
contextObjectAzure Function execution context
requestObjectRequest object. Contains body, headers, and query objects with any parameters
status<number>FunctionSet the HTTP status code
send<object>FunctionSet the JSON body
_validateFunctionInternal method for schema validation
Usage

request

Get input parameters.

// get parameters
const {
  body: { foo },
  query: { name }
} = this.request

// use them

status

this.status(404)

send

You can just return the object from your function. But you can also use send.

this.send({
  foo: 'bar'
})

joi

Look at Joi docs.

invoke

invoke is a helper for invoking functions when writing your tests.

Parameters
NameTypeDescription
namestringFunction name, should correspond to a directory
requestObjectOptional. Request object, may contain body, headers, and query objects
Usage
invoke('hello', {
  headers: {
    authorization: 'Bearer ...'
  },
  query: {
    name: 'Ali'
  }
})

FAQs

Package last updated on 21 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc