git clone https://github.com/Rakhmadi/Lavoca.git
cd Lavoca
deno run -A --unstable app.ts
Install denon
deno install -A -f -q --unstable https://deno.land/x/[email protected]/denon.ts
Run App Using Denon
denon start
└── your_project/ ├── .core ├── controller ├── middleware ├── model ├── res/ │ ├── assets │ └── view ├── routers/ │ └── router.ts ├── app.ts ├── config.ts ├── config.Example.ts ├── database.sqlite ├── denon.json └── lavoca.ts
Create Controller
deno run -A --unstable lavoca.ts --make:controller < name_controller >
Create Model
deno run -A --unstable lavoca.ts --make:model < name_model >
Create Middleware
deno run -A --unstable lavoca.ts --make:middleware < name_middleware >
Show Router list
deno run -A --unstable lavoca.ts --show:router
Basic Routes
Route.get("/",async(ctx)=>{ return ctx.response.body = 'Hello World' })
Available Router Methods
Route.get('/path', async(ctx)=>{}); Route.post('/path', async(ctx)=>{}); Route.put('/path', async(ctx)=>{}); Route.patch('/path', async(ctx)=>{}); Route.delete('/path', async(ctx)=>{}); Route.options('/path', async(ctx)=>{}); Route.head('/path', async(ctx)=>{}); // Registering A Route For Multiple Route.match(['get','post'],'/path', async(ctx)=>{}); // Allow all method Route.any('/path', async(ctx)=>{});
Routes Parameters
Route.get("/path/:id",async(ctx)=>{ return ctx.response.body = ctx.params.id })
Add Controller In Routes
import { ControllerRoute as Controller } from '../.core/controller___.ts' Route.get("/path",await Controller.set("NameFileController", "Function"))
Routes Middleware
import { module_middleware } from '../middleware/file_middleware.ts' Route.get("/path",async(ctx)=>{ return ctx.response.body = 'Hello World' },[ module_middleware ])
Routes Prefix Group
// http://localhost:8000/v1/name // group /v1 Route.prefix('/v1',()=>{ Route.get("/name",async(ctx)=>{ return ctx.response.body = 'Hello World' }) })
Routes Middleware Group
import { module_middleware } from '../middleware/file_middleware.ts' // middleware group module_middleware Route.middleware([module_middleware],()=>{ Route.get("/name",async(ctx)=>{ return ctx.response.body = 'Hello World' }) }) // prefix group /v1 // middleware group module_middleware Route.middleware([module_middleware],()=> { Route.prefix('/v1',()=>{ Route.get("/name",async(ctx)=>{ return ctx.response.body = 'Hello World' }) }) })
View Routes
// default get method Route.view('/path','file_ejs')