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);
|
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) =>
|
export const findApplicationById = async (id: string) =>
|
||||||
pool.one<ApplicationDBEntry>(sql`
|
pool.one<ApplicationDBEntry>(sql`
|
||||||
select ${sql.join(Object.values(fields), sql`, `)}
|
select ${sql.join(Object.values(fields), sql`, `)}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { generateOidcClientMetadata } from '@/oidc/utils';
|
||||||
import {
|
import {
|
||||||
deleteApplicationById,
|
deleteApplicationById,
|
||||||
findApplicationById,
|
findApplicationById,
|
||||||
|
findAllApplications,
|
||||||
insertApplication,
|
insertApplication,
|
||||||
updateApplicationById,
|
updateApplicationById,
|
||||||
} from '@/queries/application';
|
} from '@/queries/application';
|
||||||
|
@ -16,6 +17,11 @@ import { AuthedRouter } from './types';
|
||||||
const applicationId = buildIdGenerator(21);
|
const applicationId = buildIdGenerator(21);
|
||||||
|
|
||||||
export default function applicationRoutes<T extends AuthedRouter>(router: T) {
|
export default function applicationRoutes<T extends AuthedRouter>(router: T) {
|
||||||
|
router.get('/applications', async (ctx, next) => {
|
||||||
|
ctx.body = await findAllApplications();
|
||||||
|
return next();
|
||||||
|
});
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
'/application',
|
'/application',
|
||||||
koaGuard({
|
koaGuard({
|
||||||
|
|
Loading…
Reference in a new issue