@tribeca/api-gateway

    1.2.9 • Public • Published

    api-gateway

    Api Gateway library package

    Npm Version Actions Status CodeFactor codecov Dependabot Status

    A simple api gateway built on the top of expressJs.

    Installation

    $ npm install @tribeca/api-gateway --save
    

    Example

    const apiGateway = require("@tribeca/api-gateway");
    const corsMiddleware = require("./cors-middleware");
    
    const app = apiGateway();
    
    app.registerMiddleware("cors", corsMiddleware);
    
    const listen = app.initialize({
        mappingFilePath: "./mapping.json"
    });
    
    const port = process.PORT || 3000;
    listen(port, function() {
        console.log(`Server listening at port ${port}`);
    });

    Where mapping.json is

    {
        "version": 1,
        "headers": {
            "X-Api-Gateway": "api-gateway"
        },
        "middlewares": ["cors"],
        "services": [
            {
                "name": "test",
                "protocol": "http",
                "host": "127.0.0.1",
                "port": "3001",
                "basePath": "/subpath",
                "middlewares": [],
                "mappings": [
                    {
                        "path": "/test",
                        "method": "GET",
                        "middlewares": []
                    }
                ]
            }
        ]
    }

    License

    Licensed under MIT.

    Install

    npm i @tribeca/api-gateway

    DownloadsWeekly Downloads

    4

    Version

    1.2.9

    License

    MIT

    Unpacked Size

    12.5 kB

    Total Files

    11

    Last publish

    Collaborators

    • francesco.rivola
    • juanjofp