Skip to content

Instantly share code, notes, and snippets.

@stonecharioteer
Last active June 12, 2025 15:16
Show Gist options
  • Save stonecharioteer/35b0c909a09b0f20d84c5643bfe857f4 to your computer and use it in GitHub Desktop.
Save stonecharioteer/35b0c909a09b0f20d84c5643bfe857f4 to your computer and use it in GitHub Desktop.

πŸ§ͺ Developer Exercise: Redirecting Express.js Service in TypeScript

Objective:

Create a minimal Express.js web service using TypeScript with two endpoints. This exercise tests your understanding of:

HTTP redirect status codes

Routing in Express

TypeScript integration

Real-world testing with curl

πŸ“‹ Requirements:

  1. Endpoint 1 β€” /start

This route must respond to GET requests with a redirect to /destination.

Use a relevant HTTP 3xx status code (e.g., 302 or 307).

Ensure the Location header is properly set to /destination.

  1. Endpoint 2 β€” /destination

This route must respond to GET requests with:

{ "message": "You have reached the destination!", "timestamp": "" }

Return status code 200 OK.

πŸ§ͺ What You Need to Do:

Implement this using Express.js with TypeScript.

Start the service on port 3000.

Test your implementation using curl:

First, fetch the /start endpoint without following the redirect. You should see the raw 3xx response and the Location header.

Then, figure out how to make curl follow the redirect and reach /destination, verifying the final payload.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment