1.1.2 • Published 3 years ago

config-express-app v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Config Express App Build Status

Config Express App help us setup basic express app

Functions:

/**
 * @method setup Setup Express App
 * @param app Express instance
 * @param staticDir object { dirname: string; publicDir: string }: dirname: current direct, publicDir: Folder name you want to set public folder
 * @param origin string: IP address or domain name of origin call api to your web server
 * @param config CorsOptions: Configure cors for your web server
 * @param parser boolean: If true configure accept json, parse body and cookie to json object, ortherwise false
 */
function setup(app: Express, staticDir: { dirname: string; publicDir: string }, origin: string, config: CorsOptions | undefined = undefined, parser: boolean = true): void;
/**
 * @method route Set root route
 * @param app Express instance
 * @param path string: Path of root route
 * @param route Router instance
 */
function route(app: Express, path: string, route: Router): void;

Example:

    // ES6
    import express from "express";
    import RootRoute from "/your-root-route";
    const app = express();
    const ORIGIN = process.env.ORIGIN;

    const staticDir = { dirname: __dirname, publicDir: "public" };

    // Setup Express app
    setup(app, staticDir, ORIGIN); // config and parser are default setup

    // Set root route
    route(app, "/api", RootRoute);
    .....
1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.1.2

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago