mocksaml/services/apps.ts
2022-02-05 22:34:55 +05:30

33 lines
662 B
TypeScript

import { PrismaClient } from '@prisma/client';
import type { App } from '../types';
const prisma = new PrismaClient();
const create = async function(name: string, description: string, acsUrl: string, entityId: string): Promise<App> {
const body = {
name,
description,
acs_url: acsUrl,
entity_id: entityId,
}
return await prisma.app.create({ data: body });
}
const getAll = async function(): Promise<App[]> {
return await prisma.app.findMany();
}
const getById = async function(id: string): Promise<App | null> {
return await prisma.app.findUnique({
where: {
id,
},
});
}
export {
create,
getAll,
getById,
}