feat(siloadjustments): added email for comments :D
This commit is contained in:
12
server/globalUtils/greetingEmail.ts
Normal file
12
server/globalUtils/greetingEmail.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { getHours } from "date-fns";
|
||||
export const greetingStuff = async (date = new Date()) => {
|
||||
const hour = getHours(date);
|
||||
|
||||
if (hour < 12) {
|
||||
return "Good morning";
|
||||
} else if (hour < 18) {
|
||||
return "Good afternoon";
|
||||
} else {
|
||||
return "Good evening";
|
||||
}
|
||||
};
|
||||
11
server/globalUtils/singleUseKey.ts
Normal file
11
server/globalUtils/singleUseKey.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import crypto from "crypto";
|
||||
|
||||
export const generateOneTimeKey = async (length = 32) => {
|
||||
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
let key = "";
|
||||
const bytes = crypto.randomBytes(length);
|
||||
for (let i = 0; i < length; i++) {
|
||||
key += chars[bytes[i] % chars.length];
|
||||
}
|
||||
return key.match(/.{1,4}/g)!.join("-"); // group by 4 chars
|
||||
};
|
||||
Reference in New Issue
Block a user