feat: add creation date to shortlinks #13

Merged
Leon Schmidt merged 2 commits from cloudy/cloudflare-workers-url-shortener:feat/creation-date into main 2026-04-18 13:26:05 +02:00
Collaborator

Closes #11

Changes

  • Store createdAt timestamp (ISO 8601) when creating new shortlinks
  • Display creation date in admin dashboard table
  • Backward compatible: handles both old string format and new object format
  • Redirect logic updated to extract target from new object structure

Data structure

Old: {"shortname": "https://target.url"}
New: {"shortname": {"target": "https://target.url", "createdAt": "2026-04-18T12:00:00.000Z"}}

Existing shortlinks will show "-" for creation date since they don't have the timestamp.

Closes #11 ## Changes - Store `createdAt` timestamp (ISO 8601) when creating new shortlinks - Display creation date in admin dashboard table - Backward compatible: handles both old string format and new object format - Redirect logic updated to extract target from new object structure ## Data structure Old: `{"shortname": "https://target.url"}` New: `{"shortname": {"target": "https://target.url", "createdAt": "2026-04-18T12:00:00.000Z"}}` Existing shortlinks will show "-" for creation date since they don't have the timestamp.
- Store createdAt timestamp when creating new shortlinks
- Display creation date in admin dashboard table
- Backward compatible: handles both old string format and new object format
- Redirect logic updated to extract target from new object structure
Owner

@cloudy Did anything change regarding the API format? It seems like you cannot set a creation date by yourself (which is good), is that correct?

@cloudy Did anything change regarding the API format? It seems like you cannot set a creation date by yourself (which is good), is that correct?
Author
Collaborator

Yes, that's correct! The createdAt is generated on the server side using new Date().toISOString(), you can't include it in the request body. The client only sends name and target, and the timestamp is set automatically.

See lines 218–223 in src/index.js:

temp[body.name] = {
  target: body.target,
  createdAt: new Date().toISOString()
}

This prevents timestamp manipulation and ensures consistent, trustworthy creation times.

Yes, that's correct! The `createdAt` is generated on the server side using `new Date().toISOString()`, you can't include it in the request body. The client only sends `name` and `target`, and the timestamp is set automatically. See lines 218–223 in `src/index.js`: ```javascript temp[body.name] = { target: body.target, createdAt: new Date().toISOString() } ``` This prevents timestamp manipulation and ensures consistent, trustworthy creation times.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
leon/cloudflare-workers-url-shortener!13
No description provided.