mirror of
https://github.com/PreMiD/PreMiD.git
synced 2026-04-06 04:41:58 +02:00
Compare commits
5 Commits
api-master
...
api-worker
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6bad90919 | ||
|
|
ee21bb9dec | ||
|
|
6efac4fef1 | ||
|
|
93424793bd | ||
|
|
affcb6a0cf |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@premid/api-master",
|
||||
"type": "module",
|
||||
"version": "0.0.18",
|
||||
"version": "0.0.20",
|
||||
"private": true,
|
||||
"description": "PreMiD's api master",
|
||||
"license": "MPL-2.0",
|
||||
|
||||
@@ -78,7 +78,7 @@ export async function clearOldSessions() {
|
||||
|
||||
async function deleteSession(session: { token: string; session: string }, key: string): Promise<string> {
|
||||
const abortController = new AbortController();
|
||||
const timeoutId = setTimeout(() => abortController.abort(), 5000); //* 5 second timeout
|
||||
const timeoutId = setTimeout(() => abortController.abort("Timeout"), 5000); //* 5 second timeout
|
||||
|
||||
try {
|
||||
const discord = new REST({ version: "10", authPrefix: "Bearer" });
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@premid/api-worker",
|
||||
"type": "module",
|
||||
"version": "0.0.8",
|
||||
"version": "0.0.9",
|
||||
"private": true,
|
||||
"description": "PreMiD's api",
|
||||
"license": "MPL-2.0",
|
||||
|
||||
@@ -8,13 +8,17 @@ import { redis } from "../functions/createServer.js";
|
||||
const schema = type({
|
||||
token: "string.trim",
|
||||
session: "string.trim",
|
||||
version: "string.semver & string.trim",
|
||||
scienceId: "string.trim",
|
||||
});
|
||||
|
||||
export async function sessionKeepAlive(request: FastifyRequest, reply: FastifyReply) {
|
||||
//* Get the 2 headers
|
||||
//* Get the headers
|
||||
const out = schema({
|
||||
token: request.headers["x-token"],
|
||||
session: request.headers["x-session"],
|
||||
version: request.headers["x-version"] ?? "2.6.8",
|
||||
scienceId: request.headers["x-science-id"] ?? request.headers["x-token"],
|
||||
});
|
||||
|
||||
if (out instanceof type.errors)
|
||||
@@ -25,7 +29,7 @@ export async function sessionKeepAlive(request: FastifyRequest, reply: FastifyRe
|
||||
|
||||
await redis.hset(
|
||||
"pmd-api.sessions",
|
||||
out.token,
|
||||
out.scienceId,
|
||||
JSON.stringify({
|
||||
session: out.session,
|
||||
token: out.token,
|
||||
|
||||
Reference in New Issue
Block a user