1.2.9 • Published 5 years ago

@tribeca/api-gateway v1.2.9

Weekly downloads
9
License
MIT
Repository
github
Last release
5 years ago

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.

1.2.9

5 years ago

1.2.7

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

0.0.12

5 years ago