- v3.0.0-beta.2Latest
- v3.0.0-beta.1
- v3.0.0-preview.4
- v2.8.1
- v2.7.1
- v2.7.0
- v2.6.0
- v2.5.4
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.0
- v2.0.0-rc-2
- v2.0.1-rc-1
- v2.0.0-beta-1
- v2.0.0-beta
- v1.5.1
- v1.5.0
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.1
- v1.3.0
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v1.0.0-rc1
- v0.42.0
- v0.41.1
- v0.41.0
- v0.39.6
- v0.39.5
- v0.39.4
- v0.39.3
- v0.39.2
- v0.39.1
- v0.39.0
- v0.38.0
- v0.37.1
- v0.37.0
- v0.36.0
- v0.35.2
- v0.35.1
- v0.35.0
- v0.34.0
- v0.33.1
- v0.33.0
- v0.32.0
- v0.31.3
- v0.31.2
- v0.31.1
- v0.31.0
- v0.30.1
- v0.30.0
- v0.29.0
- v0.28.3
- v0.28.2
- v0.28.1
- v0.28.0
- v0.27.6
- v0.27.5
- v0.27.4
- v0.27.3
- v0.27.2
- v0.27.1
- v0.27.0
- v0.26.0
- v0.25.0
- v0.24.1
- v0.24.0
- v0.23.0
- v0.22.2
- v0.22.1
- v0.22.0
- v0.21.0
- v0.20.1
- v0.20.0
- v0.19.1
- v0.19.0
- v0.18.1
- v0.18.0
- v0.17.0
- v0.16.2
- v0.16.1
- v0.16.0
- v0.15.0
- v0.14.0
- v0.13.0
- v0.12.0
- v0.11.0
- v0.10.0
- v0.9.0
- v0.8.6
- v0.8.5
- v0.8.4
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.9
- v0.7.8
- v0.7.7
- v0.7.6
- v0.7.5
- v0.7.4
- v0.7.3
- v0.7.2
- v0.7.1
- v0.7.0
- v0.6.2
- v0.6.1
- v0.6.0
- v0.6.0-alpha.6
Drash
Drash is a microframework for Deno based on HTTP resources and content negotiation.
Drash is designed to help you build your project(s) quickly with the ability to scale. You can build an API, a SaaS, a web app, an SPA (like the documentation pages), or even a static HTML site. How you use Drash is up to you, so that it can be everything you need and nothing you donât.
Features
HTTP Resources
Drash uses HTTP resources. It doesnât use controllers and it doesnât use app.get('/', someHandler())
-like syntax. You create a resource class, define its URIs, and give it HTTP methods (e.g., GET()
, POST()
, PUT()
, DELETE()
, etc.).
Static Paths
Drash servers can handle requests for static assets like CSS files, JS files, and more. Depending on your use case (like building a web app with your own custom stylesheets and scripts), you might want to serve static assets. To do this, just include your list of static paths in the Drash serverâs static_paths
config.
Request Path Params (e.g., /users/:id
)
Resources can access their URIâs path params via this.request.path_params.some_param
âallowing you to build RESTful/ish APIs.
Request URL Query Params (e.g., /users?id=1234
)
Resources can access the requestâs URL query params via this.request.url_query_params.some_param
.
Request Body (e.g., {"id":"1234"}
)
Resources can access the requestâs body via this.request.body_parsed.some_param
. Supported content types are application/json
and application/x-www-form-urlencoded
.
Semantic Method Names
If you want your resource class to allow GET
requests, then give it a GET()
method. If you want your resource class to allow POST
requests, then give it a POST()
method. If you donât want your resource class to allow DELETE
requests, then donât give your resource class a DELETE()
method. Pretty simple ideology and very semantic.
Content Negotiation
Drash is based on resources and you canât have true resources unless clients can request different representations of those resources through content negotiation. Out of the box, Drashâs Drash.Http.Response
class can generate the following representations for resources: application/json
, text/html
, application/xml
, and text/xml
. Getting the Drash.Http.Response
class to handle more representations is easy. Read the Adding Content Types tutorial for more information.
Install
// Import Drash latest release
import Drash from "https://deno.land/x/drash@v0.8.6/mod.ts";
// Import Drash master
import Drash from "https://deno.land/x/drash/mod.ts";
It is recommended that you import the latest release or a specific release to prevent breaking changes. Drashâs master branch tries to keep up with the latest Deno code (including deno_std) and is subject to Denoâs âdisruptive renamesâ as stated in deno_std.
Quickstart
Create app.ts
âŚ
import Drash from "https://deno.land/x/drash@v0.8.6/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:8000",
response_output: "text/html",
resources: [HomeResource]
});
server.run();
⌠and run app.ts
$ deno --allow-net --allow-env app.ts
Deno server started at localhost:8000. Press CTRL+C to quit.
For a more complicated application, try out the Hello World tutorial series!