resources-adapter
v2.6.16
Published
### 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 cus
Downloads
4
Readme
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=