0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

feat(core): GET /applications (#107)

This commit is contained in:
Gao Sun 2021-09-01 20:51:34 +08:00 committed by GitHub
parent 5d5d43deee
commit ed204f91c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -9,6 +9,12 @@ import RequestError from '@/errors/RequestError';
const { table, fields } = convertToIdentifiers(Applications);
export const findAllApplications = async () =>
pool.many<ApplicationDBEntry>(sql`
select ${sql.join(Object.values(fields), sql`, `)}
from ${table}
`);
export const findApplicationById = async (id: string) =>
pool.one<ApplicationDBEntry>(sql`
select ${sql.join(Object.values(fields), sql`, `)}

View file

@ -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<T extends AuthedRouter>(router: T) {
router.get('/applications', async (ctx, next) => {
ctx.body = await findAllApplications();
return next();
});
router.post(
'/application',
koaGuard({