2022-01-13 17:07:44 +00:00
|
|
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
2022-01-13 17:50:16 +00:00
|
|
|
import { metadata } from '../../../services';
|
2022-01-13 17:07:44 +00:00
|
|
|
import type { App, IdPMetadata } from '../../../types';
|
|
|
|
|
|
|
|
|
|
export default async function handler(
|
|
|
|
|
req: NextApiRequest,
|
|
|
|
|
res: NextApiResponse<App | App[] | IdPMetadata | null>
|
|
|
|
|
) {
|
|
|
|
|
if (req.method === 'POST') {
|
|
|
|
|
return await create(req);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function create(req: NextApiRequest) {
|
|
|
|
|
const {
|
2022-01-13 17:50:16 +00:00
|
|
|
acs_url,
|
|
|
|
|
entity_id,
|
2022-01-13 17:07:44 +00:00
|
|
|
name = 'My App',
|
|
|
|
|
description = null,
|
|
|
|
|
} = req.body;
|
|
|
|
|
|
2022-01-13 17:50:16 +00:00
|
|
|
const certificate = 'EwZHb29nbGUxGDAWBgNVBAsTD0dv';
|
2022-01-13 17:07:44 +00:00
|
|
|
|
2022-01-13 17:50:16 +00:00
|
|
|
return res
|
|
|
|
|
.status(200)
|
|
|
|
|
.json(metadata.create(acs_url, entity_id, certificate));
|
2022-01-13 17:07:44 +00:00
|
|
|
|
2022-01-13 17:50:16 +00:00
|
|
|
// const app = await apps.create({
|
|
|
|
|
// acs_url,
|
|
|
|
|
// entity_id,
|
|
|
|
|
// name,
|
|
|
|
|
// description,
|
|
|
|
|
// certificate,
|
|
|
|
|
// });
|
2022-01-13 17:07:44 +00:00
|
|
|
|
2022-01-13 17:50:16 +00:00
|
|
|
// return res.status(200).json(app);
|
2022-01-13 17:07:44 +00:00
|
|
|
}
|
|
|
|
|
}
|