URL Shortener track · step 6 of 8 Back to the trackDesign a URL shortener
Level 3 of 5 / you are the scheduler
The vanity alias race
A URL shortener lets people pick a custom alias. Alice and Bob both want /launch. The handler checks that it is free, then saves it.
Your goal: make one of these false
- An alias has exactly one ownernot checked yet
Aliceapi-1
- const owner = await db.get("alias:/launch");
- if (owner !== null) return "TAKEN";
- await db.set("alias:/launch", "alice");
- return "CLAIMED";
no local variables yet
Bobapi-2
- const owner = await db.get("alias:/launch");
- if (owner !== null) return "TAKEN";
- await db.set("alias:/launch", "bob");
- return "CLAIMED";
no local variables yet
Database
- alias_owner
- null
What happened
- Step a request to begin.
0 steps · 0 switches · par 2