adding support for appsumo codes

This commit is contained in:
Emily
2024-11-07 17:06:53 +01:00
parent b4c0620f17
commit 4d7cfbb7b9
5 changed files with 126 additions and 2 deletions

View File

@@ -0,0 +1,13 @@
import { AppsumoCodeModel } from '@schema/AppsumoCode'
export async function checkAppsumoCode(code: string) {
const target = await AppsumoCodeModel.exists({ code, used_at: { $exists: false } });
return target;
}
export async function useAppsumoCode(code: string) {
await AppsumoCodeModel.updateOne({ code }, { used_at: Date.now() });
}