Drash logo

Drash

A microframework for Deno focused on resource creation and content negotiation.


// File: app.ts

import Drash from "https://deno.land/x/drash/mod.ts";

class HomeResource extends Drash.Http.Resource {
  static paths = ["/"];
  public GET() {
    this.response.body = "Hello World!";
    return this.response;
  }
}

let server = new Drash.Http.Server({
  address: "localhost:1337",
  response_output: "text/html",
  resources: [HomeResource]
});

server.run();
$ deno --allow-net app.ts

Documentation

For full documentation, visit https://drash.land.

Features

  • Content Negotiation
  • Static Path Routing
  • Regex Path Routing (e.g., /users/([0-9]+)/profile)
  • Middleware
  • Request Params Parsing
    • Path Params (e.g., /users/:id/profile, /users/{id}/profile)
      • request.getPathParam("id") == "value of :id or {id}"
    • URL Query Params (e.g., /products?name=beignet&action=purchase)
      • request.getQueryParam("name") == beignet
    • Body Params Using application/x-www-form-urlencoded (e.g., username=root&password=alpine)
      • request.getBodyParam("username") == "root"
    • Body Params Using application/json (e.g., {"username":"root","password":"alpine"})
      • request.getBodyParam("password") == "alpine"
    • Header Params (e.g., {"Some-Header":"Some Value"})
      • request.getHeaderParam("Some-Header") == "Some Value"
      • … or the default way (request.headers.get("Some-Header") == "Some Value")

Contributing

Contributors are welcomed!