Writing a Web Server with Oak
Explore how to write a web server in Deno using the Oak framework, focusing on creating middleware, adding event listeners for application start and error events, and improving development feedback. This lesson guides you through migrating from the standard HTTP module to Oak, enhancing your application's routing and user management.
We'll cover the following...
Using Oak for web applications
We decided that we’ll be using Oak in this course. In this lesson, we’ll rewrite part of our web application so that we can use it instead of the HTTP module from the standard library.
Let’s open src/web/index.ts and start tackling it step by step.
Following Oak’s documentation, the only thing we’ll need to do is instantiate the Application object, define a middleware, and call the listen method. Let’s do it:
- Add Oak’s import to the
deps.tsfile:
export {Application} from "https://deno.land/x/oak@v6.3.1/mod.ts"
Note: If you’re using VSCode, then you’ve probably noticed that there’s warning saying that it couldn’t find this version of ...