Writing a web server with Oak
At the end of the previous chapter, we looked at different web libraries. After a brief analysis, we ended up choosing Oak. In this section, 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 (https://deno.land/x/oak@v6.3.1), 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.ts
file:export { Application } from "https://deno.land/x/oak@v6.3.1/mod.ts"
If you are using VSCode, then you've probably noticed that there is warning saying that it couldn't find this version of the dependency locally.
- Let's run the commands from the previous section to download it and add it to the lock file.
Do not forget to do...