Skip to content

API for timed.cc — a fast and lightweight serverless backend for storing temporary encrypted links using KV

License

Notifications You must be signed in to change notification settings

yerofey/api.timed.cc

Repository files navigation

api.timed.cc

Backend API for timed.cc — a quick cross-device link sharing service using short codes and QR.

This API is built with Hono and runs on Cloudflare Workers, using Cloudflare KV for temporary link storage.


Local Development

bun i
bun run dev

Deploy to Cloudflare

bun run deploy

API Endpoints

GET /

Get the API information.

Response: JSON object with the following fields:

  • message: A welcome message.
  • version: The version of the API.
{
  "message": "Welcome to the timed.cc API",
  "version": "1.0.0"
}

POST /create

Create a new short link.

Request: JSON object with the following fields:

  • encryptedUrl: The encrypted URL to be shortened.
{
  "encryptedUrl": "U2FsdGVkX1/IGvUkIgxEmxSM6kitLRMVCgAroho0bCQqw+HaAcQpGk5X+f2jXMMI"
}

Response: JSON object with the following fields:

  • code: The generated short code.
  • expiresAt: The timestamp when the short link will expire.
{
  "code": "A12345",
  "expiresAt": 1699999999999
}

GET /resolve/:code

Resolve a short code to its original URL.

Request: URL parameter code (the short code).

  • code: The short code to resolve.
{
  "code": "A12345"
}

Response: JSON object with the following fields:

  • encryptedUrl: The encrypted URL.
{
  "encryptedUrl": "U2FsdGVkX1/IGvUkIgxEmxSM6kitLRMVCgAroho0bCQqw+HaAcQpGk5X+f2jXMMI"
}

GET /ping

Check if the API is running.

Response: JSON object with the following fields:

  • status: The status of the API.
  • timestamp: The current timestamp.
{
  "status": "ok",
  "timestamp": 1699999999999
}

Notes

  • All codes expire after 5 minutes using KV TTL.
  • CORS is enabled for all origins by default in development.
  • Keys are stored using Cloudflare Workers KV (c.env.timed).
  • Use the /admin/list endpoint only in local/dev mode — never expose it in production without protection.
  • Error handling is included for invalid input and failed KV access.

Tech Stack

Author

Yerofey S.

License

MIT

About

API for timed.cc — a fast and lightweight serverless backend for storing temporary encrypted links using KV

Resources

License

Stars

Watchers

Forks