1.1.0 • Published 4 years ago

medisot-base-server v1.1.0

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

npm.io PAUL A handy base server for inversify based express applications. How to use To use, create a new instance of the BaseServer by providing the necessary constructor arguments:

let baseServer = new BaseServer(AppFactory, container, serverConfig);
  1. AppFactory: A function that returns the express app. e.g.

    const AppFactory = (app, cluster) => {
       app.get("*", (req: any, res: any) => {
           res.send("Please send a valid request");
       })
    
       app.listen(8080);
    
       return app;
    }
  2. Containers: The inversify container used in the express app for DI. e.g.

    let container = new Container();

container.bind(HyperledgerClientTypes.Connection).toConstantValue(Connection);


3. ServerConfig: A callback with a single argument(app) that adds various configurations to the app e.g. <br/>

const config = (app) => { // app configurations app.use(bodyParser.json()) app.use(bodyParser.urlencoded({ extended: true })) app.use(cookieParser()) }

After initializing the BaseServer, call the run method to start the application.

baseServer.run()