Home Manual Reference Source
import App from 'koa-smart/src/App.js'
public class | source

App

Constructor Summary

Public Constructor
public

Method Summary

Public Methods
public

addMiddleware(middleware: function[]):

adds the provided function to the list of Koa middlewares to be executed for all routes.

public

addMiddlewares(middlewares: function):

adds the provided functions to the list of Koa middlewares to be executed for all routes.

public

mountFolder(pathFolder: string, prefix: string):

"mounts" a folder, scanning it for route files, then adding the discovered routes to the app.

public

async start(): Koa

Launches the app and starts listening on the configured port.

Public Constructors

public constructor() source

Public Methods

public addMiddleware(middleware: function[]): source

adds the provided function to the list of Koa middlewares to be executed for all routes.

Params:

NameTypeAttributeDescription
middleware function[]

an array of middlewares

Return:

public addMiddlewares(middlewares: function): source

adds the provided functions to the list of Koa middlewares to be executed for all routes.

Params:

NameTypeAttributeDescription
middlewares function

an array of Koa-compliant middlewares

Return:

public mountFolder(pathFolder: string, prefix: string): source

"mounts" a folder, scanning it for route files, then adding the discovered routes to the app. a route is a class which extends Route

Params:

NameTypeAttributeDescription
pathFolder string

the path of the folder to mount

prefix string
  • optional
  • default: '/'

an optional prefix to prepend to all of the folder's routes

Return:

public async start(): Koa source

Launches the app and starts listening on the configured port.

Return:

Koa