MCPcopy
hub / github.com/Peppermint-Lab/peppermint / configRoutes

Function configRoutes

apps/api/src/controllers/config.ts:25–410  ·  view source on GitHub ↗
(fastify: FastifyInstance)

Source from the content-addressed store, hash-verified

23}
24
25export function configRoutes(fastify: FastifyInstance) {
26 // Check auth method
27 fastify.get(
28 "/api/v1/config/authentication/check",
29
30 async (request: FastifyRequest, reply: FastifyReply) => {
31 const config = await prisma.config.findFirst();
32
33 //@ts-expect-error
34 const { sso_active, sso_provider } = config;
35
36 if (sso_active) {
37 reply.send({
38 success: true,
39 sso: sso_active,
40 provider: sso_provider,
41 });
42 }
43
44 reply.send({
45 success: true,
46 sso: sso_active,
47 });
48 }
49 );
50
51 // Update OIDC Provider
52 fastify.post(
53 "/api/v1/config/authentication/oidc/update",
54
55 async (request: FastifyRequest, reply: FastifyReply) => {
56 const { clientId, clientSecret, redirectUri, issuer, jwtSecret }: any =
57 request.body;
58
59 const conf = await prisma.config.findFirst();
60
61 await prisma.config.update({
62 where: { id: conf!.id },
63 data: {
64 sso_active: true,
65 sso_provider: "oidc",
66 },
67 });
68
69 const existingProvider = await prisma.openIdConfig.findFirst();
70
71 if (existingProvider === null) {
72 await prisma.openIdConfig.create({
73 data: {
74 clientId: clientId,
75 redirectUri: redirectUri,
76 issuer: issuer,
77 },
78 });
79 } else {
80 await prisma.openIdConfig.update({
81 where: { id: existingProvider.id },
82 data: {

Callers 1

registerRoutesFunction · 0.90

Calls 2

createTransportProviderFunction · 0.90
trackingFunction · 0.70

Tested by

no test coverage detected