diff --git a/src/routes/applications/index.json.ts b/src/routes/applications/index.ts
similarity index 100%
rename from src/routes/applications/index.json.ts
rename to src/routes/applications/index.ts
diff --git a/src/routes/new/application/index.json.ts b/src/routes/applications/new.ts
similarity index 81%
rename from src/routes/new/application/index.json.ts
rename to src/routes/applications/new.ts
index b8d25fc63..62d55edf6 100644
--- a/src/routes/new/application/index.json.ts
+++ b/src/routes/applications/new.ts
@@ -6,10 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event);
if (status === 401) return { status, body };
-
- const { name } = await event.request.json();
- if (!name) return { status: 400, body: { error: 'Missing name.' } };
-
+ const name = uniqueName();
try {
const { id } = await db.newApplication({ name, teamId });
return { status: 201, body: { id } };
diff --git a/src/routes/dashboard.json.ts b/src/routes/dashboard.json.ts
index 226a76a37..4c3ed3097 100644
--- a/src/routes/dashboard.json.ts
+++ b/src/routes/dashboard.json.ts
@@ -8,12 +8,22 @@ export const get: RequestHandler = async (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;
+ const applicationsCount = await db.prisma.application.count({
+ where: { teams: { some: { id: teamId } } }
+ });
+ const sourcesCount = await db.prisma.gitSource.count({
+ where: { teams: { some: { id: teamId } } }
+ });
+ const destinationsCount = await db.prisma.destinationDocker.count({
+ where: { teams: { some: { id: teamId } } }
+ });
+ const teamsCount = await db.prisma.permission.count({ where: { userId } });
+ const databasesCount = await db.prisma.database.count({
+ where: { teams: { some: { id: teamId } } }
+ });
+ const servicesCount = await db.prisma.service.count({
+ where: { teams: { some: { id: teamId } } }
+ });
return {
body: {
applicationsCount,
diff --git a/src/routes/databases/index.svelte b/src/routes/databases/index.svelte
index f476b3c66..f6834cd0b 100644
--- a/src/routes/databases/index.svelte
+++ b/src/routes/databases/index.svelte
@@ -1,24 +1,3 @@
-
-
diff --git a/src/routes/databases/index.json.ts b/src/routes/databases/index.ts
similarity index 99%
rename from src/routes/databases/index.json.ts
rename to src/routes/databases/index.ts
index 17ff3c779..29cdad39c 100644
--- a/src/routes/databases/index.json.ts
+++ b/src/routes/databases/index.ts
@@ -6,6 +6,7 @@ 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 };
+
try {
const databases = await db.listDatabases(teamId);
return {
diff --git a/src/routes/new/database/index.json.ts b/src/routes/databases/new.ts
similarity index 83%
rename from src/routes/new/database/index.json.ts
rename to src/routes/databases/new.ts
index a774aff84..86bf028bf 100644
--- a/src/routes/new/database/index.json.ts
+++ b/src/routes/databases/new.ts
@@ -1,4 +1,4 @@
-import { getUserDetails } from '$lib/common';
+import { getUserDetails, uniqueName } from '$lib/common';
import * as db from '$lib/database';
import { ErrorHandler } from '$lib/database';
import type { RequestHandler } from '@sveltejs/kit';
@@ -6,9 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event);
if (status === 401) return { status, body };
-
- const { name } = await event.request.json();
-
+ const name = uniqueName();
try {
const { id } = await db.newDatabase({ name, teamId });
return { status: 201, body: { id } };
diff --git a/src/routes/new/application/import.json.ts b/src/routes/new/application/import.json.ts
deleted file mode 100644
index 495bc3dcf..000000000
--- a/src/routes/new/application/import.json.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { getUserDetails } from '$lib/common';
-import * as db from '$lib/database';
-import { ErrorHandler } from '$lib/database';
-import type { RequestHandler } from '@sveltejs/kit';
-
-export const post: RequestHandler = async (event) => {
- const { teamId, status, body } = await getUserDetails(event);
- if (status === 401) return { status, body };
-
- let { name, fqdn, port, buildCommand, startCommand, installCommand } = await event.request.json();
-
- if (fqdn) fqdn = fqdn.toLowerCase();
- if (port) port = Number(port);
-
- try {
- const { id } = await db.importApplication({
- name,
- teamId,
- fqdn,
- port,
- buildCommand,
- startCommand,
- installCommand
- });
- return { status: 201, body: { id } };
- } catch (error) {
- return ErrorHandler(error);
- }
-};
diff --git a/src/routes/new/application/index.svelte b/src/routes/new/application/index.svelte
deleted file mode 100644
index 0f267fd85..000000000
--- a/src/routes/new/application/index.svelte
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
diff --git a/src/routes/new/database/index.svelte b/src/routes/new/database/index.svelte
deleted file mode 100644
index 4ee9ee6fb..000000000
--- a/src/routes/new/database/index.svelte
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
diff --git a/src/routes/new/service/index.svelte b/src/routes/new/service/index.svelte
deleted file mode 100644
index f658a4ec2..000000000
--- a/src/routes/new/service/index.svelte
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
diff --git a/src/routes/services/index.svelte b/src/routes/services/index.svelte
index 1ea70b904..a4d34cd5f 100644
--- a/src/routes/services/index.svelte
+++ b/src/routes/services/index.svelte
@@ -1,24 +1,3 @@
-
-
diff --git a/src/routes/services/index.json.ts b/src/routes/services/index.ts
similarity index 100%
rename from src/routes/services/index.json.ts
rename to src/routes/services/index.ts
diff --git a/src/routes/new/service/index.json.ts b/src/routes/services/new.ts
similarity index 91%
rename from src/routes/new/service/index.json.ts
rename to src/routes/services/new.ts
index 3594f7920..2faad169c 100644
--- a/src/routes/new/service/index.json.ts
+++ b/src/routes/services/new.ts
@@ -6,9 +6,7 @@ import type { RequestHandler } from '@sveltejs/kit';
export const post: RequestHandler = async (event) => {
const { teamId, status, body } = await getUserDetails(event);
if (status === 401) return { status, body };
-
- const { name } = await event.request.json();
-
+ const name = uniqueName();
try {
const { id } = await db.newService({ name, teamId });
return { status: 201, body: { id } };
diff --git a/src/routes/teams/index.svelte b/src/routes/teams/index.svelte
index c8572d5fc..05c020cdf 100644
--- a/src/routes/teams/index.svelte
+++ b/src/routes/teams/index.svelte
@@ -91,23 +91,21 @@