New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

serverless-http-utils

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-http-utils

Serverless HTTP utils

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Serverless HTTP Utils

A small utils package that simplifies REST handlers inside Serverless APIs.

Requirements

  • A Serverless API using node v14 or later
  • ApiGateway configured to use the v2 event

Installation

$ yarn add serverless-http-utils
or
$ npm install serverless-http-utils

Usage

Wrap any exported Serverless handler with the handler method and return a new instance of HttpSuccess:

import { handler, Event, HttpSuccess } from 'serverless-http-utils';

export const handle = handler((event: Event) => {
  return new HttpSuccess(200, { hello: 'world' });
});

Errors can be thrown anywhere by throwing a HttpException:

import { HttpException } from 'serverless-http-utils';

async function authenticate(token: string): void {
  if (!token) {
    throw new HttpException(401, 'Token not provided');
  }
}

See the example/ folder for more info.

Contributing

Clone the repository:

$ git clone git@github.com:lemonJS/serverless-http-utils.git

Install dependencies:

$ yarn install

Run the tests:

$ yarn test

FAQs

Package last updated on 11 Jan 2022

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