mocksaml/services/apps.ts

33 lines
662 B
TypeScript
Raw Normal View History

2022-01-13 17:07:44 +00:00
import { PrismaClient } from '@prisma/client';
import type { App } from '../types';
const prisma = new PrismaClient();
2022-02-05 17:04:55 +00:00
const create = async function(name: string, description: string, acsUrl: string, entityId: string): Promise<App> {
const body = {
name,
description,
acs_url: acsUrl,
entity_id: entityId,
}
2022-01-13 17:07:44 +00:00
return await prisma.app.create({ data: body });
}
2022-02-05 17:04:55 +00:00
const getAll = async function(): Promise<App[]> {
2022-01-13 17:07:44 +00:00
return await prisma.app.findMany();
}
2022-02-05 17:04:55 +00:00
const getById = async function(id: string): Promise<App | null> {
2022-01-13 17:07:44 +00:00
return await prisma.app.findUnique({
where: {
id,
},
});
}
2022-02-05 17:04:55 +00:00
export {
create,
getAll,
getById,
}