-
Notifications
You must be signed in to change notification settings - Fork 711
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
21 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,21 @@ | ||
import { ratelimit } from "./upstash"; | ||
|
||
export async function checkLicenseKey(licenseKey: string) { | ||
const response = await fetch(`https://api.lemonsqueezy.com/v1/license-keys`, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${process.env.LEMON_API_KEY ?? ""}`, | ||
}, | ||
}); | ||
const keysData = await response.json(); | ||
const licenseKeys = keysData.data?.map((i: any) => { | ||
console.log("========i.attributes========", i.attributes); | ||
return i.attributes.key; | ||
}); | ||
|
||
if (licenseKeys?.includes(licenseKey.toLowerCase())) { | ||
// TODO: change to supabase after implement user-login | ||
const { remaining } = await ratelimit.limit(licenseKey.toLowerCase()); | ||
// TODO: log to hit licenseKey | ||
console.log( | ||
`!!!!!!!!! {short-xxxx-licenseKey}, remaining: ${remaining} ========` | ||
); | ||
return remaining > 0; | ||
} | ||
|
||
return false; | ||
export async function activeLicenseKey(licenseKey: string, bvId?: string) { | ||
// https://docs.lemonsqueezy.com/help/licensing/license-api | ||
const response = await fetch( | ||
`https://api.lemonsqueezy.com/v1/licenses/activate`, | ||
{ | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${process.env.LEMON_API_KEY ?? ""}`, | ||
}, | ||
body: JSON.stringify({ | ||
license_key: licenseKey, | ||
instance_name: bvId || "b.jimmylv.cn", | ||
}), | ||
} | ||
); | ||
const result = await response.json(); | ||
return result.actived; | ||
} |
eae586e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
chat-bilibili-video – ./
bilibili.jimmylv.cn
chat-bilibili-video-jimmylv.vercel.app
chat-bilibili-video.vercel.app
chat-bilibili-video-git-main-jimmylv.vercel.app
m.bilibili.jimmylv.cn
b.jimmylv.cn
www.bilibili.jimmylv.cn