commit 36e1c9272fa9b86cbe9e53e03e83799820674f17 Author: zomars <zomars@me.com> Date: Tue Jul 26 18:27:57 2022 -0600 Update [schedule].tsx commit f39535feea22a11a857d179f3506803602a95728 Author: zomars <zomars@me.com> Date: Tue Jul 26 18:07:30 2022 -0600 Update [status].tsx commit c3ac1bcc8c7ff8dc7ebf178d23a6e5c7ea223749 Author: zomars <zomars@me.com> Date: Tue Jul 26 17:53:43 2022 -0600 Update [schedule].tsx commit 39364d8476b3c582d4a7fe3f8d139c5d254e3ecf Author: zomars <zomars@me.com> Date: Tue Jul 26 17:43:13 2022 -0600 Debugging prod commit 4b428d22dec734dab19096b4fe07741f18e5bc5d Author: zomars <zomars@me.com> Date: Tue Jul 26 17:20:44 2022 -0600 Update checkLicense.ts commit 4212e6d61908face52d647bb661d71db959cf864 Author: zomars <zomars@me.com> Date: Tue Jul 26 17:11:37 2022 -0600 Booking fixes attempt commit e3160027ea0ce40d129b445daeb3bb17711ac640 Author: zomars <zomars@me.com> Date: Tue Jul 26 13:52:35 2022 -0600 migration conflict fixes
26 lines
697 B
TypeScript
26 lines
697 B
TypeScript
import cache from "memory-cache";
|
|
|
|
import { CONSOLE_URL } from "@calcom/lib/constants";
|
|
|
|
const CACHING_TIME = 86400000; // 24 hours in milliseconds
|
|
|
|
async function checkLicense(license: string): Promise<boolean> {
|
|
if (!!process.env.NEXT_PUBLIC_IS_E2E) return true;
|
|
const url = `${CONSOLE_URL}/api/license?key=${license}`;
|
|
const cachedResponse = cache.get(url);
|
|
if (cachedResponse) {
|
|
return cachedResponse;
|
|
} else {
|
|
try {
|
|
const response = await fetch(url, { mode: "cors" });
|
|
const data = await response.json();
|
|
cache.put(url, data.valid, CACHING_TIME);
|
|
return data.valid;
|
|
} catch (error) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
export default checkLicense;
|