Skip to content

Variable: buildEntrypoints ​

const buildEntrypoints: (options) => EntrypointOptions

Type the options of the Entrypoint component; they are returned as they are. The applications of the lakutata package declare the entrypoint as the component entrypoint: give these options to it.

Parameters ​

options ​

EntrypointOptions

The controllers, middlewares, access rules and the adapters of each channel.

Returns ​

EntrypointOptions

The same options, to declare as the entrypoint component.

Example ​

typescript
import {Application, DTO} from 'lakutata'
import {buildEntrypoints, Controller, scheduleEntrypoint} from 'lakutata/com/entrypoint'
import {GET, POST, Schedule} from 'lakutata/decorator/ctrl'
import {Expect} from 'lakutata/decorator/dto'
import {expressHTTPEntrypoint} from 'lakutata/adapter/express'

class CreateOrderDTO extends DTO {
    @Expect(DTO.String().required())
    public product: string
}

class OrderController extends Controller {
    @GET('/orders', {name: 'listOrders', groups: ['orders']})
    public async list(): Promise<string[]> {
        return []
    }

    @POST('/orders', CreateOrderDTO, {name: 'createOrder', groups: ['orders']})
    public async create(input: CreateOrderDTO): Promise<{product: string}> {
        return {product: input.product}
    }

    @Schedule('0 * * * *')
    public async purge(): Promise<void> {
    }
}

Application.run(() => ({
    id: 'shop.app',
    name: 'Shop',
    components: {
        entrypoint: buildEntrypoints({
            controllers: [OrderController],
            httpActionGroups: {orders: 'Orders'},
            shutdownTimeout: 10000,
            http: expressHTTPEntrypoint({port: 3000}),
            schedule: scheduleEntrypoint()
        })
    },
    bootstrap: ['entrypoint']
}))

Released under the MIT License.