settings + reinvite players to lobby
This commit is contained in:
27
src/routes/api/health/+server.ts
Normal file
27
src/routes/api/health/+server.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
// src/routes/api/health/+server.ts
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { db } from '$lib/server/db';
|
||||
import { sql } from 'drizzle-orm';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
export const GET: RequestHandler = async () => {
|
||||
try {
|
||||
// Check DB connectivity
|
||||
await db.execute(sql`SELECT 1`);
|
||||
|
||||
return json({
|
||||
status: 'ok',
|
||||
timestamp: new Date().toISOString(),
|
||||
uptime: process.uptime()
|
||||
});
|
||||
} catch (e: any) {
|
||||
return json(
|
||||
{
|
||||
status: 'error',
|
||||
error: 'Database connection failed',
|
||||
timestamp: new Date().toISOString()
|
||||
},
|
||||
{ status: 503 }
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
// src/routes/api/matches/+server.ts
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import { db } from '$lib/server/db';
|
||||
import { createMatch } from '$lib/server/match/engine';
|
||||
@@ -35,7 +36,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
createdBy: locals.user.id
|
||||
});
|
||||
return json(result, { status: 201 });
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
error(400, e.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// src/routes/api/matches/[id]/+server.ts
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import { getMatchFull, cancelMatch } from '$lib/server/match/engine';
|
||||
import type { RequestHandler } from './$types';
|
||||
@@ -8,7 +9,7 @@ export const GET: RequestHandler = async ({ params, locals }) => {
|
||||
try {
|
||||
const m = await getMatchFull(params.id);
|
||||
return json(m);
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
error(404, e.message);
|
||||
}
|
||||
};
|
||||
@@ -19,7 +20,7 @@ export const DELETE: RequestHandler = async ({ params, locals }) => {
|
||||
try {
|
||||
const m = await cancelMatch(params.id);
|
||||
return json(m);
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
error(400, e.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// src/routes/api/matches/[id]/lobby/+server.ts
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import { moveToLobby } from '$lib/server/match/engine';
|
||||
import type { RequestHandler } from './$types';
|
||||
@@ -10,7 +11,7 @@ export const POST: RequestHandler = async ({ params, request, locals }) => {
|
||||
try {
|
||||
const m = await moveToLobby(params.id, body.osuLobbyId);
|
||||
return json(m);
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
error(400, e.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// src/routes/api/matches/[id]/pick/+server.ts
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import { pickMap } from '$lib/server/match/engine';
|
||||
import type { RequestHandler } from './$types';
|
||||
@@ -13,7 +14,7 @@ export const POST: RequestHandler = async ({ params, request, locals }) => {
|
||||
try {
|
||||
const game = await pickMap(params.id, participantId, mappoolSlotId);
|
||||
return json(game);
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
error(400, e.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// src/routes/api/matches/[id]/roll/+server.ts
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import { submitRoll } from '$lib/server/match/engine';
|
||||
import type { RequestHandler } from './$types';
|
||||
@@ -13,7 +14,7 @@ export const POST: RequestHandler = async ({ params, request, locals }) => {
|
||||
try {
|
||||
const m = await submitRoll(params.id, participantId, value);
|
||||
return json(m);
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
error(400, e.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// src/routes/api/matches/[id]/rolling/+server.ts
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import { moveToRolling } from '$lib/server/match/engine';
|
||||
import type { RequestHandler } from './$types';
|
||||
@@ -8,7 +9,7 @@ export const POST: RequestHandler = async ({ params, locals }) => {
|
||||
try {
|
||||
const m = await moveToRolling(params.id);
|
||||
return json(m);
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
error(400, e.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// src/routes/api/matches/[id]/score/+server.ts
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import { submitGameScores } from '$lib/server/match/engine';
|
||||
import type { RequestHandler } from './$types';
|
||||
@@ -13,7 +14,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
try {
|
||||
const m = await submitGameScores(matchGameId, scores);
|
||||
return json(m);
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
error(400, e.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// src/routes/api/queue/+server.ts
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import { joinQueue, leaveQueue, getQueueStatus } from '$lib/server/match/engine';
|
||||
import { db } from '$lib/server/db';
|
||||
import { team, teamMember } from '$lib/server/db/schema';
|
||||
import { eq, and } from 'drizzle-orm';
|
||||
import { teamMember } from '$lib/server/db/schema';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
export const GET: RequestHandler = async ({ locals }) => {
|
||||
@@ -29,7 +30,7 @@ export const POST: RequestHandler = async ({ locals }) => {
|
||||
try {
|
||||
const result = await joinQueue(locals.user.id, personalTeam.id);
|
||||
return json({ matched: !!result, match: result });
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
error(400, e.message);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user