Spaces:
Running
Running
File size: 579 Bytes
6e13570 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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 };
|