mirror of
https://github.com/ProjectSegfault/website.git
synced 2024-11-26 08:42:04 +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 Authentik from '@auth/core/providers/authentik';
|
||||
import { env } from "$env/dynamic/private";
|
||||
import statusData from "$lib/statusData";
|
||||
import map from "$lib/map";
|
||||
|
||||
export const handle = SvelteKitAuth({
|
||||
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 statusData from "./statusData";
|
||||
|
||||
const map = new Map();
|
||||
|
||||
const updateMap = () => {
|
||||
map.set("data", {
|
||||
status: statusData,
|
||||
updated: Math.floor(Date.now() / 1000)
|
||||
});
|
||||
};
|
||||
|
||||
updateMap();
|
||||
|
||||
setInterval(updateMap, 60000);
|
||||
import map from "$lib/map";
|
||||
|
||||
export const GET = (() => {
|
||||
const data = map.get("data");
|
||||
|
Loading…
Reference in New Issue
Block a user