mirror of
https://github.com/ProjectSegfault/website.git
synced 2024-12-22 21:19:51 +05:30
make status api faster
This commit is contained in:
parent
27269d2476
commit
b812dabed5
@ -1,6 +1,8 @@
|
|||||||
import { SvelteKitAuth } from "@auth/sveltekit"
|
import { SvelteKitAuth } from "@auth/sveltekit"
|
||||||
import Authentik from '@auth/core/providers/authentik';
|
import Authentik from '@auth/core/providers/authentik';
|
||||||
import { env } from "$env/dynamic/private";
|
import { env } from "$env/dynamic/private";
|
||||||
|
import statusData from "$lib/statusData";
|
||||||
|
import map from "$lib/map";
|
||||||
|
|
||||||
export const handle = SvelteKitAuth({
|
export const handle = SvelteKitAuth({
|
||||||
providers: [
|
providers: [
|
||||||
@ -12,3 +14,14 @@ export const handle = SvelteKitAuth({
|
|||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const updateMap = () => {
|
||||||
|
map.set("data", {
|
||||||
|
status: statusData,
|
||||||
|
updated: Math.floor(Date.now() / 1000)
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
updateMap();
|
||||||
|
|
||||||
|
setInterval(updateMap, 30000);
|
3
src/lib/map.ts
Normal file
3
src/lib/map.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const map = new Map();
|
||||||
|
|
||||||
|
export default map;
|
@ -1,18 +1,5 @@
|
|||||||
import type { RequestHandler } from './$types';
|
import type { RequestHandler } from './$types';
|
||||||
import statusData from "./statusData";
|
import map from "$lib/map";
|
||||||
|
|
||||||
const map = new Map();
|
|
||||||
|
|
||||||
const updateMap = () => {
|
|
||||||
map.set("data", {
|
|
||||||
status: statusData,
|
|
||||||
updated: Math.floor(Date.now() / 1000)
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
updateMap();
|
|
||||||
|
|
||||||
setInterval(updateMap, 60000);
|
|
||||||
|
|
||||||
export const GET = (() => {
|
export const GET = (() => {
|
||||||
const data = map.get("data");
|
const data = map.get("data");
|
||||||
|
Loading…
Reference in New Issue
Block a user