Spaces:
Running
Running
Download src/utils/orderNumber.js from AndreaNotes1/auth-app-api: direct link, hf CLI and curl.
- Browser
- Download file 579 Bytes
-
https://huggingface.co/spaces/AndreaNotes1/auth-app-api/resolve/main/src/utils/orderNumber.js
- Command line
-
hf download hf://spaces/AndreaNotes1/auth-app-api/src/utils/orderNumber.js
-
curl -L -o orderNumber.js https://huggingface.co/spaces/AndreaNotes1/auth-app-api/resolve/main/src/utils/orderNumber.js
579 Bytes
| const crypto = require("crypto"); | |
| /** | |
| * Human-friendly, hard-to-guess order number, e.g. AYN-20260825-4F9K2C. | |
| * Not used as a security token (the order is always looked up by its | |
| * MongoDB _id + the requesting user's identity), just a reference the | |
| * customer can quote in support emails. | |
| */ | |
| function generateOrderNumber() { | |
| const date = new Date().toISOString().slice(0, 10).replace(/-/g, ""); | |
| const random = crypto.randomBytes(4).toString("hex").toUpperCase().slice(0, 6); | |
| return `AYN-${date}-${random}`; | |
| } | |
| module.exports = { generateOrderNumber }; | |