@booster-ts/express-module
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

ExpressModule

An Express Wrapper for booster-ts.

Getting Started

Installation

$ npm i @booster-ts/express-module @types/express

Setting Up

In you project package.json you will need to add the field express-module in the field booster

"booster": {
    "express-module": 3000
}

If the port is specified in a environment variable you can just put the env name as the value for expres-module. ExpressModule defaults to 3000 if not property is set.

Starting the server

To start the server you will need to call the init method in ExpressModule.

Injecting ExpressModule

import { booster } from '@booster-ts/core'
import { ExpressModule} from '@booster-ts/ExpressModule';
import { Express } from 'express';

@booster()
export class Router {

    private app: Express;

    constructor(
        express: ExpressModule
    ) {
        this.app = express.getApp();
        this.app.get('/', (req, res) => {
            res.json({
                code: "00",
                text: "OK"
            })
        });
    }
}

To access the express server, you will need to call the getApp() method. You will then be able to add new Routes.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.1
    0
    • beta
  • 0.0.1
    0
    • latest

Version History

Package Sidebar

Install

npm i @booster-ts/express-module

Weekly Downloads

0

Version

0.0.1

License

ISC

Unpacked Size

6.21 kB

Total Files

7

Last publish

Collaborators

  • imoverlord