2.6.16 • Published 4 years ago

resources-adapter v2.6.16

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

resources-adapter: a RESTFull API abstraction

Motivation:

Based on the hexagonal architecture's concept of adapters, this module removes the complexities and risks inherent to the development activities, centralizes HTTP(S) adapter's setup premises avoiding mistakes from developers. It can be customized at will when premises change.

Usage:

    // First instantiate an Express application
    let configs: RestfullServerOptionsInterface = {}; // See interfaces

    let app: Express = restfullServer(configs);
    // then you can just get a HTTP server from that by listening to a port
    app.listen(process.env.PORT);

Types:

    export interface RestfullServerOptionsInterface
    {
        corsPolicy?: CorsPolicyInterface;
        exposedResources: ResourcesDescriptorInterface[];
        authorizationConfigs?: AuthorizationConfig[];
    };
    export interface CorsPolicyInterface
    {
        allowOrigin: string;
        allowMethods: string;
        allowedHeaders: string;
    };
    export interface ResourcesDescriptorInterface
    {
        basePath: string;
        handler: Router;
        isBearerAuthorized?: boolean;
        isBasicAuthorized?: boolean;
    };

    export interface AuthorizedResource
    {
        basePath: string;
        schemas: AuthSchemas[];
    };

    export interface AuthorizationConfig
    {
        isEnabled: boolean;
        schema: string;
        audience: string;
        issuer: string;
        kid?: string;
        authKey?: string;
        algorithms: any[];
    };

    export interface CustomRequest extends Request
    {
        claims: any;
    };

    export interface CustomErrorInterface extends Error
    {
        code?: number;
        fullDescription?: string;
    };

    export interface IResponseError
    {
        code: number;
        message: string;
    };

Demanded ENVs:

LISTEN_PORT=
HMAC_KEY=
HMAC_SALT=
DUMB_PASSWORD=
DUMB_USERNAME=
JWT_ALGO=
RSA_PUB_KEY=
ALLOWED_APPLICATIONS=
2.6.16

4 years ago

1.6.14

4 years ago

1.61.5

4 years ago

1.6.10

4 years ago

1.6.9

4 years ago

1.6.8

4 years ago

1.6.7

4 years ago

1.5.7

4 years ago

1.3.6

4 years ago

1.2.6

4 years ago

1.1.4

4 years ago

1.0.2

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago