Catalog npm
Back to packageRELEASE DETAILS

1.3.0

npm

@0to10/aws-api-gateway-handler

Typescript library for setting up Lambda functions to serve as API Gateway handler

api gatewayawsexpresslambda
Published26 Jun 2025
Direct dependencies19
Transitive dependenciesNot calculated

README

Current package documentation

AWS API Gateway Handler

This repository provides a bootstrapper when creating Node.js Lambda functions, to be used as API Gateway handlers.

Getting started

Get started quickly by following the instructions below.

Installation

Use NPM to install this library into your project:

npm install --save @0to10/aws-api-gateway-handler

Setup

Quick setup:

'use strict';

import http from 'http';

import {Application, Request, Response} from '@0to10/aws-api-gateway-handler';

const application: Application = new Application();

// Any application logic, such as registering routes, may be added after instantiation
application.express.get('/test', (
    _request: Request,
    response: Response,
): void => {
    response.status(200).json({
        message: 'Test was a success!',
    });
});

application.listen(80);

// Expose the handler
export const handler = application.handler.bind(application);

Configuration

You may optionally pass in configuration options to the constructor of the Application class, as follows:

import {Application, Configuration} from '@0to10/aws-api-gateway-handler';

const config: Configuration = {
    disable: [
        'x-powered-by',
        'etag',
    ],
    cors: false,
};

const application: Application = new Application(config);

Below is an overview of the configuration options available.

OptionTypeDefault
disablestring[]['x-powered-by']
corsbooleantrue

A full list of available features that may be disabled (via the disable option) is available on the Express.js website.

Events

Various events are emitted within this library, you may attach listeners to the events by following the example below:

// Application bootstrap omitted

application.events.on('listening', (port: number): void => {
    console.log('Listening on port ' + port);
});

Below is an overview of the available events.

EventArgumentsNotes
listening(port: number)Emitted when the server is ready to process requests
event(event: APIGatewayProxyEvent)Emitted every time a request is handled
debug:error(error: any)Emitted whenever the error handler handles an error

AWS Cognito

This library exposes a cognito object on the Request object of Express to make Cognito user data easily accessible. See the type below.

type CognitoRequestInformation = {
    identityId?: string;
    userPoolId?: string;
    username?: string;
}

Note that request.cognito will always be an object, but any of the values may be undefined.

// Application bootstrap omitted

application.express.get('/test', (
    request: express.Request,
    _response: express.Response,
): void => {
    console.info('Cognito user:', {
        cognitoIdentityId: request.cognito.identityId,
        cognitoUserPoolId: request.cognito.userPoolId,
        cognitoUsername: request.cognito.username,
    });
});

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 19

Native requirements
19 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
aws-serverless-express
Environment
{
  "local_name": "aws-serverless-express",
  "alias": false,
  "peer_metadata": null
}
^3.4.0runtime
express
Environment
{
  "local_name": "express",
  "alias": false,
  "peer_metadata": null
}
^4.18.2runtime
express-async-errors
Environment
{
  "local_name": "express-async-errors",
  "alias": false,
  "peer_metadata": null
}
^3.1.1runtime
@jest/globals
Environment
{
  "local_name": "@jest/globals",
  "alias": false,
  "peer_metadata": null
}
^29.5.0development
@types/aws-lambda
Environment
{
  "local_name": "@types/aws-lambda",
  "alias": false,
  "peer_metadata": null
}
~8.10.122development
@types/aws-serverless-express
Environment
{
  "local_name": "@types/aws-serverless-express",
  "alias": false,
  "peer_metadata": null
}
~3.3.6development
@types/express
Environment
{
  "local_name": "@types/express",
  "alias": false,
  "peer_metadata": null
}
^4.17.21development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
~18.17.19development
@types/supertest
Environment
{
  "local_name": "@types/supertest",
  "alias": false,
  "peer_metadata": null
}
^6.0.2development
@types/type-is
Environment
{
  "local_name": "@types/type-is",
  "alias": false,
  "peer_metadata": null
}
^1.6.6development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^6.19.0development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^6.19.0development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^8.56.0development
eslint-plugin-deprecation
Environment
{
  "local_name": "eslint-plugin-deprecation",
  "alias": false,
  "peer_metadata": null
}
^2.0.0development
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^29.5.0development
license-checker-rseidelsohn
Environment
{
  "local_name": "license-checker-rseidelsohn",
  "alias": false,
  "peer_metadata": null
}
^4.3.0development
supertest
Environment
{
  "local_name": "supertest",
  "alias": false,
  "peer_metadata": null
}
^7.0.0development
ts-jest
Environment
{
  "local_name": "ts-jest",
  "alias": false,
  "peer_metadata": null
}
^29.1.0development
tslib
Environment
{
  "local_name": "tslib",
  "alias": false,
  "peer_metadata": null
}
^2.2.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-yKKEXXrgI8r8OfZ9UlKZnAGUbGqJ7oAhpDjfirh4efT0lwz96c/NKENwq0IozimSJTV2wBYcZEgrbKEyIlBOUg==",
  "shasum": "671ff6bc64e0de9e5b6e677691173b0732d5e9ce",
  "tarball": "https://registry.npmjs.org/@0to10/aws-api-gateway-handler/-/aws-api-gateway-handler-1.3.0.tgz",
  "fileCount": 87,
  "unpackedSize": 76439,
  "signatures": [
    {
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
      "sig": "MEQCIAQ5fyn/PDyqF6K0kagRkp8ftf1ALnxLKqBnWYahqjslAiBptIhFWh2wWEYaU+Tvnbmi7NsDix6LaBfZl5AGzUXYig=="
    }
  ]
}

Repository

PENDING
0to10/aws-api-gateway-handler-library-ts

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:16 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:8e4c877eda646c2c5d629ca5a3e838635c8a1f8bdb4c157bf882ecd205ca909b

Other collected versions

1.2.15 May1.2.020 Feb1.1.016 Sept1.0.812 Sept1.0.716 Aug1.0.615 AugView all collected versions →