diff --git a/packages/core/src/queries/application.ts b/packages/core/src/queries/application.ts index 99716ed79..90118a2fd 100644 --- a/packages/core/src/queries/application.ts +++ b/packages/core/src/queries/application.ts @@ -9,6 +9,12 @@ import RequestError from '@/errors/RequestError'; const { table, fields } = convertToIdentifiers(Applications); +export const findAllApplications = async () => + pool.many(sql` + select ${sql.join(Object.values(fields), sql`, `)} + from ${table} + `); + export const findApplicationById = async (id: string) => pool.one(sql` select ${sql.join(Object.values(fields), sql`, `)} diff --git a/packages/core/src/routes/application.ts b/packages/core/src/routes/application.ts index 0abedf142..c13c58193 100644 --- a/packages/core/src/routes/application.ts +++ b/packages/core/src/routes/application.ts @@ -6,6 +6,7 @@ import { generateOidcClientMetadata } from '@/oidc/utils'; import { deleteApplicationById, findApplicationById, + findAllApplications, insertApplication, updateApplicationById, } from '@/queries/application'; @@ -16,6 +17,11 @@ import { AuthedRouter } from './types'; const applicationId = buildIdGenerator(21); export default function applicationRoutes(router: T) { + router.get('/applications', async (ctx, next) => { + ctx.body = await findAllApplications(); + return next(); + }); + router.post( '/application', koaGuard({