Skip to content

🦕 Simple "convention over configuration" Controllers solution for Deno.

Notifications You must be signed in to change notification settings

adamjosefus/allo_controllers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Allo Controllers for Deno 🦕

Simple "convention over configuration" Controllers solution for Deno.

Extends the Allo Routing framework with a Controllers layer.

Controller

// ./controllers/HomepageController.ts
import { Controller } from "../../libs/Controller.ts";

export class HomepageController extends Controller {
    renderDefault() {
        this.sendText("Hello World!");
    }
}
// ./main.ts
import { Server } from "https://deno.land/x/allo_server/mod.ts";
import { ControllerManager, RouterList } from "https://deno.land/x/allo_controllers/mod.ts";

const manager = new ControllerManager("./controllers");

const router = new RouterList(manager);
router.addController("homepage/<action>", "Homepage:default");

const server = new Server(router);
server.listen({ port: 8080 });

Life Cycle

  %% Looks weird? View on github.

  flowchart TB
  A("contructor()") --> B("inject*()")
  B --> C("onStartup() && startup()")
  C --> D("action<'Action'>()")
  D --> E("beforeRender() && onRender()")
  E --> F("render<'View'>()")
  F --> G("afterRender()")
  G --> H("onShutdown() && shutdown()")

Loading

Documentation 📖

Description of all classes and methods with examples will found in the documentation.


Check out other ours packages 📦!