1.1.3 • Published 3 years ago

@peu77/expresswrapper v1.1.3

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

ExpressWrapper

install size

Simple construct for an express application.

Installation

With NPM

npm i @peu77/expresswrapper

With Yarn

yarn add @peu77/expresswrapper

You need to create a service and a controller

Imports

import {
    Controller,
    initControllers,
    RouteType,
    Service,
    generateListener,
    DependencyImpl
} from '@peu77/expresswrapper';

Basic service

const service: Service = {
    listeners: [
        generateListener(RouteType.POST, "test", (data: any) => {
            return {
                success: true,
                message: "finished",
                status: 200,
                data: {}
            }
        })
    ]
}

Basic controller which use the service

const controller: Controller = {
    prefix: "/api",
    service: service,
    routes: [
        {
            path: "test",
            type: RouteType.POST,
            guards: [],
            dependencies: []
        }
    ]
}

If you have a controller you can use the initControllers function

const app = express();
app.listen(3000, () => {
    initControllers(app, [controller]);
})
1.1.3

3 years ago

1.1.2

3 years ago

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.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