import { buildContract } from '@jig-software/trest-core';
import { z } from 'zod';

export const GetClientResult = z.object({
  secret: z.string(),
  clientId: z.string(),
});
export type GetClientResult = z.infer<typeof GetClientResult>;

export const authContract = buildContract((c) =>
  c
    .prefix('auth')
    .parse((p) =>
      p.error.text(500).error.text(400).error.text(401).error.text(403),
    )
    .endpoints({
      getClient: (e) =>
        e.method('GET').parse((p) => p.success.object(200, GetClientResult)),
    }),
);
