Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Deleted a file, oops

Andras Bacsaicfdc8db54333
diff --git a/src/routes/applications/[id]/usage.json.ts b/src/routes/applications/[id]/usage.json.ts
new file mode 100644
index 0000000000..ab161d81eb
--- /dev/null
+++ b/src/routes/applications/[id]/usage.json.ts
@@ -0,0 +1,30 @@
+import { getUserDetails } from '$lib/common';
+import * as db from '$lib/database';
+import { ErrorHandler } from '$lib/database';
+import { getContainerUsage } from '$lib/haproxy';
+import type { RequestHandler } from '@sveltejs/kit';
+
+export const get: RequestHandler = async (event) => {
+ const { teamId, status, body } = await getUserDetails(event);
+ if (status === 401) return { status, body };
+
+ const { id } = event.params;
+
+ let usage = {};
+ try {
+ const application = await db.getApplication({ id, teamId });
+ if (application.destinationDockerId) {
+ [usage] = await Promise.all([getContainerUsage(application.destinationDocker.engine, id)]);
+ }
+ return {
+ status: 200,
+ body: {
+ usage
+ },
+ headers: {}
+ };
+ } catch (error) {
+ console.log(error);
+ return ErrorHandler(error);
+ }
+};