import { Router } from "https://deno.land/x/dactyl@v0.1.0-alpha/mod.ts";
Router subclass - abstraction on top of Router
class from Oak.
exposes methods Router.register()
and router.middleware()
to
Application
class for bootstrapping Oak application
Methods
Helper that updates the internal bootstrap message. Used on application start to display on screen success.
Helper method for constructing controller action arguments from metadata on the controller.
Helper method for handling non-standard exceptions raised at runtime. This could be caused by an unhandled promise rejection, or a custom error thrown either internally or from an external module.
Dactyl will send a 500 error to the end user.
Helper function for deconstructing Oaks RouterContext
context
object. Retreives context.params
, context.request.headers
,
context.request.url.searchParams
, and context.request.body()
and maps them appropriately
Helper method called when controller action returns no json, and
RouterContext
context.response.body
contains no body
middleware getter for the internal router. To be used in Application
bootstrap
where appropriate, E.g.
// From Oak
const app: Application = new Application();
// From Dactyl
const router: Router = new Router();
// ... register controllers ...
app.use(router.middleware());
// routes now mapped to oak
Register function consumed by Application
, takes controller
class definition and strips it's metadata. From this metadata,
the register
function appropriately configures super()
oak
router. An instance of the provided controller class definition
is created, and the controller's actions are mapped to routes,
E.g.
import { DinosaurController } from "./example/DinosaurController.ts";
const router: Router = new Router();
router.register(DinosaurController);
// router superclass now configured to use DinosaurController's actions