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

api-getaway-testing

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-getaway-testing

module to test the api-getaway lambda integration

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

api-getaway-testing

api-getaway testing server

Usage

const assert = require('assert');

const supertest = require('supertest');

const apiGetway = require('api-getaway-testing');

const api = apiGetway({
    '/test':(event, ctx, cb) => {
        assert(event.queryStringParameters);
        assert(event.pathParameters);
        assert(event.headers);
        assert(event.body.test === 'test');
        assert(event.httpMethod);
        assert(event.path);
        assert(event.requestContext);
        assert(event.stageVariables);

        cb(null, {
            statusCode:202,
            body:'response',
            headers:{
                'Content-Type':'application/text'
            }
        });
    },

    '/test/other/:params':{
        post: (event, ctx, cb) => {
            assert(event.queryStringParameters.query === 'query');
            assert(event.pathParameters.params === 'params');
            assert(event.headers);
            assert(event.body.data === 'data');
            assert(event.httpMethod === 'POST');
            assert(event.path === '/test/other/params');
            assert(event.requestContext);
            assert(event.stageVariables);

            cb(null, {
                statusCode:201,
                body: { response:'response' },
                headers:{
                    'Content-Type':'application/json'
                }
            });
        }
    }
}, 4000);

const agent = supertest(api);


const res = await agent.get('/test')
    .send({test:'test'})
    .expect(202);
assert(res.text === 'response');


const res = await agent.post('/test/other/params')
    .query({ query:'query' })
    .send({ data:'data' })
    .expect(201);
assert.deepEqual(res.body, { response :'response' });
assert(res.headers['content-type'] === 'application/json; charset=utf-8');

API getApiGetawayTesting(object, port = 3000, app = express()) -> appServer

Receive a object what is a map between path and lambda handler:

{
    path: handler
}

or

{
    path: {
        method: handler,
        otherMethod: otherHandler
    }
}

You can pass a express instance with all middleware already attached.

The only middleware attached by getApiGetawayTesting is body-parser.

Keywords

FAQs

Package last updated on 19 Mar 2018

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