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

x/opineHttpProxy/test/deps.ts>Application

Proxy middleware for Deno Opine HTTP servers.
Latest
interface Application
implements IRouter, [Opine.Application]
import { type Application } from "https://deno.land/x/opineHttpProxy@3.2.0/test/deps.ts";

Call Signatures

(req: OpineRequest, res?: OpineResponse): void

Opine instance itself is a request handler, which could be invoked without third argument.

Properties

get: ((setting: string) => any) & IRouterMatcher<this>
router: string
settings: any
locals: any
routes: any

The app.routes object houses all of the routes defined mapped by the associated HTTP verb. This object may be used for introspection capabilities, for example Opine uses this internally not only for routing but to provide default OPTIONS behaviour unless app.options() is used. Your application or framework may also remove routes by simply by removing them from this object.

_router: Router

Used to get all registered routes in Opine Application

mountpath: string | string[]

The app.mountpath property contains one or more path patterns on which a sub-app was mounted.

cache: any
parent: any
engines: any

Methods

init(): void

Initialize the server.

  • setup default configuration
  • setup default middleware
  • setup route reflection methods
defaultConfiguration(): void

Initialize application configuration.

lazyrouter(): void

Lazily adds the base router if it has not yet been added.

We cannot add the base router in the defaultConfiguration because it reads app settings which might be set after that has run.

set(setting: string, value?: any): this

Assign setting to val, or return setting's value.

app.set('foo', 'bar'); app.get('foo'); // => "bar"

Mounted servers inherit their parent server's settings.

param(name: string | string[], fn: RequestParamHandler): this
path(): string

Return the app's absolute pathname based on the parent(s) that have mounted it.

For example if the application was mounted as "/admin", which itself was mounted as "/blog" then the return value would be "/blog/admin".

enabled(setting: string): boolean

Check if setting is enabled (truthy).

app.enabled('foo') // => false

app.enable('foo') app.enabled('foo') // => true

disabled(setting: string): boolean

Check if setting is disabled.

app.disabled('foo') // => true

app.enable('foo') app.disabled('foo') // => false

enable(setting: string): this

Enable setting.

disable(setting: string): this

Disable setting.

listen(): Server

Listen for connections.

A Deno Server is returned.

listen(port: number, callback?: () => void): Server
listen(addr: string, callback?: () => void): Server
listen(options: HTTPOptions, callback?: () => void): Server
listen(options: HTTPSOptions, callback?: () => void): Server
on(event: string, callback: (args: any) => any): any

The mount event is fired on a sub-app, when it is mounted on a parent app. The parent app is passed to the callback function.

NOTE: Sub-apps will:

  • Not inherit the value of settings that have a default value. You must set the value in the sub-app.
  • Inherit the value of settings with no default value.
emit(event: string, arg: any): any

Emit an event using the applications event emitter.

Events will be raised based on the passed event string and any listening on() methods will receive the passed arg as an argument.

engine(ext: string, fn: (
path: string,
options: Record<string, unknown>,
callback: (e: any, rendered: string) => void,
) => void
): this

Register the given template engine callback fn for the provided extension ext.

render(
name: string,
options?: any,
callback?: (err: Error, html: string) => void,
): void

Render the given view name name with options and a callback accepting an error and the rendered template string.

Example:

app.render('email', { name: 'Deno' }, function(err, html) { // ... })

render(name: string, callback: (err: Error, html: string) => void): void