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:
parent
5d5d43deee
commit
ed204f91c5
2 changed files with 12 additions and 0 deletions
|
@ -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`, `)}
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in a new issue