mirror of
https://github.com/ershisan99/coolify.git
synced 2026-01-26 05:02:13 +00:00
fix: hook.ts - relogin needed
updated packages fix: Lots of typescript thingy fix: ssl request flow fix: proxy cleanup flow
This commit is contained in:
50
src/routes/dashboard.json.ts
Normal file
50
src/routes/dashboard.json.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { getTeam, getUserDetails } from '$lib/common';
|
||||
import * as db from '$lib/database';
|
||||
import { ErrorHandler } from '$lib/database';
|
||||
import type { RequestHandler } from '@sveltejs/kit';
|
||||
|
||||
export const get: RequestHandler = async (event) => {
|
||||
const { userId, teamId, status, body } = await getUserDetails(event);
|
||||
if (status === 401) return { status, body };
|
||||
|
||||
try {
|
||||
const applicationsCount = await (await db.listApplications(teamId)).length;
|
||||
const sourcesCount = await (await db.listSources(teamId)).length;
|
||||
const destinationsCount = await (await db.listDestinations(teamId)).length;
|
||||
const teamsCount = await (await db.getMyTeams({ userId })).length;
|
||||
const databasesCount = await (await db.listDatabases(teamId)).length;
|
||||
const servicesCount = await (await db.listServices(teamId)).length;
|
||||
return {
|
||||
body: {
|
||||
applicationsCount,
|
||||
sourcesCount,
|
||||
destinationsCount,
|
||||
teamsCount,
|
||||
databasesCount,
|
||||
servicesCount
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
return ErrorHandler(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const post: RequestHandler = async (event) => {
|
||||
const { status, body } = await getUserDetails(event, false);
|
||||
if (status === 401) return { status, body };
|
||||
|
||||
const { cookie, value } = await event.request.json();
|
||||
const from = event.url.searchParams.get('from') || '/';
|
||||
|
||||
return {
|
||||
status: 302,
|
||||
body: {},
|
||||
headers: {
|
||||
'set-cookie': [
|
||||
`${cookie}=${value}; HttpOnly; Path=/; Max-Age=15778800;`,
|
||||
'gitlabToken=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT'
|
||||
],
|
||||
Location: from
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user