Prerequisites
You can skip to the Next Steps at the bottom of this page or you can skip this page entirely if you already have a JavaScript runtime installed and have an HTTP server set up in that runtime.
1. Choose a Runtime
You will need to choose a JavaScript runtime that:
- fits your use case(s); and
- provides APIs to create an HTTP server (e.g.,
http.createServer(...)
in Node v18.x orDeno.serve(...)
in Deno v1.37.x).
You could run Drash in the browser, but these documentation pages are written assuming you are using Drash to build server-side HTTP applications. Pages discussing how to build applications in the browser will be written at a later time.
2. Install the Runtime
After choosing a runtime, you will need to install it on your machine (or the machine you plan to use). You can do this by following your chosen runtime's documentation pages (typically under an "installation" page or similar).
3. Create an HTTP Server
Once your chosen runtime is installed and ready to be used, follow its documentation pages on creating an HTTP server. When you have an HTTP server set up, head back to this page and check out the Next Steps below.
Unlike previous versions of Drash where Drash is a Deno HTTP server wrapper under the hood, Drash v3 is an agnostic codebase that can be used to create different types of functionality. This means Drash v3 does not provide APIs to create HTTP servers like what we did in v2.x. Sorry!
What does creating an HTTP server mean?
When we say "creating an HTTP server," we mean writing some code that can listen for HTTP requests. As an example, if you chose Deno v1.37.1 and wanted to create an HTTP server in it, that code could look like:
Deno.serve({
port: 1447,
hostname: "localhost",
handler: (request) => {
console.log({ request });
return new Response("Hello!");
},
});
Taking this a step further, you could run the above code using:
deno run --allow-net app.ts
When the code is running (aka when the HTTP server is running), it would be listening for HTTP requests. This means if you go to http://localhost:1447
in your browser (aka make an HTTP request to http://localhost:1447
), then you would see Hello!
on the page (because the request is handled with a return new Response("Hello!")
in the code).
Next Steps
Feel free to follow our recommendation or navigate the documentation pages at your leisure.
Our Recommendations
- Create a tiny HTTP application using the Request Chain module