Skip to content

Latest commit

 

History

History
20 lines (13 loc) · 1.46 KB

kata-02.md

File metadata and controls

20 lines (13 loc) · 1.46 KB

Deno kata 2 - Creating a server

The purpose of this kata is to build a web server with Deno.

Learning aims

The idea here is to get a Deno server running and cover the following:

  • Setting up a Deno server
  • Creating an API endpoint
  • Testing the endpoint

Task

Complete the following:

  1. Create a Deno server that exposes GET /hello endpoint and returns string Hello world! with status 200. For anything else, return Not found with status 404. Hint: It is a good idea to use the Server class for the task although there are other ways to the same. To handle routing, check request.url. Hint: See the URL class as it can help in parsing the request. To avoid having to restart the server manually while developing, use the --watch mode when running Deno.
  2. To ensure that our server implementation works, test it using Deno test utilities. In other words, set up a test case that uses fetch to hit your endpoint and then ensure what it received matches Hello world!.
  3. Optional - Test the failure case (Not found, 404) as well.
  4. Add Deno tasks for the added server and test functionalities.