Skip to main content

Dinar

A web framework for Deno. Simple, Easy && Cool;

Quick Start

const Application = await Dinar.createApplication({ port: 8080 });

// create a controller(just a router)
@Controller()
export class HomeController {
  // create a get method
  @Get()
  helloWorld() {
    return "hello dianr";
  }
}

Application.run();

// visite http://localhost:8080 and you will see `hello dinar` in your broswer!

Router

we use Controller and other request methods decorator as router map

// visite http://localhost:8080/home/index and you can see `this is index home`
@Controller("home")
export class HomeController {
  @Get("index")
  inde() {
    return "this is index home";
  }
}

Service

Auto Dependency Inject

unlike Module in nest or Area in alosaur,you do not need to write any unnessuary import class or config statement,

just wirte you controller, we will help you to inject anything you need

// CatController.ts
import { CatService } from "./CatService.ts";
@Controller("cat")
export class CatController {
  contructor(private cs: CatService) {}
  @Get("list")
  async list() {
    return await this.cs.getList();
  }
}

// CatService.ts
@Service()
export class CatService {
  async getList() {
    return await some_database_query("sql");
  }
}

just this !

you do not write those module file that make you puzzled,

Use Cookie and Session

cookie and session are mean state in Dinar.

so we provide you a base state class named Stateful,

use it as follow

// cookie example, if you are not use Stateful,you would not get cookie
@Controller()
export class Home extends Stateful {
  @Get()
  index() {
    return this.cookie.name ?? "unlogin";
  }
  @Get("login")
  login() {
    this.cookie = {
      name: "dinar",
    };
    return "success";
  }
}