Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno_nest/src/application.ts>Application

Refer to nestjs to realize some common functions for Deno, support hono and oak
Go to Latest
class Application
import { Application } from "https://deno.land/x/deno_nest@v3.7.0/src/application.ts";

Constructors

new
Application(router: IRouter)

Properties

private
abortController: AbortController
private
apiPrefix: string
private
controllers: Type[]
private
globalExceptionFilters: ExceptionFilters
private
globalGuards: NestGuards
private
globalInterceptors: NestUseInterceptors
private
instances: Set<any>
private
logger: LoggerService | false
private
startTime
private
staticOptions: StaticOptions
moduleCaches: Map<ModuleType, FactoryCaches>

Methods

private
beforeApplicationShutdown(signal?: string): Promise<void>
private
catchFilter(
target: InstanceType<Constructor> | null,
fn: ControllerMethod | null,
context: Context,
error: any,
)
private
formatResponse(context: Context, options: { target: InstanceType<Constructor>; args: any[]; methodName: string; methodType: string; fn: ControllerMethod; })
private
initControllers(controllerArr: Constructor[], caches: FactoryCaches)
private
initModule(module: ModuleType)
private
initModules(moduleMap: Map<ModuleType, CollectResult>, modules: ModuleType[])
private
initProviders(providers: Provider[], caches: FactoryCaches)
private
onApplicationBootstrap(): Promise<void>

TODO: think about whether to use Promise.all or a for loop

private
onApplicationShutdown(signal?: string): Promise<void>

TODO: think about whether to use Promise.all or a for loop

private
onModuleDestroy(): Promise<void>
private
onModuleInit(): Promise<void>
private
validateGuard(
target: InstanceType<Constructor>,
context: Context,
): Promise<boolean>
protected
log(...message: string[])
protected
routes()
addController(...clsArr: Type[])

add controller

Close the application.

Enables the usage of shutdown hooks. Will call the onApplicationShutdown function of a provider if the process receives a shutdown signal.

get(path: string, middleware: NestMiddleware)

Only give a simple quick start example here, not recommended to use it for complex functions.

Because it is not subject to the overall framework process framework and is not associated with guards, interceptors, filters, etc.

Its execution order with middleware is also not guaranteed by the framework, for example, oak middleware will be executed first, but the hono may see the order get and middlewares.

init(appModule: ModuleType, caches?: FactoryCaches)
listen(options?: ListenOptions): Promise<void>
setGlobalPrefix(apiPrefix: string)
use(...middlewares: NestMiddleware[]): void
useLogger(logger: LoggerService | false): void

Sets custom logger service.

useOriginMiddleware(originMiddleware: Function, path?: string): void

use the origin middleware, not recommend to use if you don't know what you are doing.

useStaticAssets(path: string, options?: StaticOptions)

Sets a base directory for public assets.