mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
feat: add template and field endpoints (#1572)
This commit is contained in:
@ -12,6 +12,36 @@ export const ZRequestMetadataSchema = z.object({
|
||||
|
||||
export type RequestMetadata = z.infer<typeof ZRequestMetadataSchema>;
|
||||
|
||||
export type ApiRequestMetadata = {
|
||||
/**
|
||||
* The general metadata of the request.
|
||||
*/
|
||||
requestMetadata: RequestMetadata;
|
||||
|
||||
/**
|
||||
* The source of the request.
|
||||
*/
|
||||
source: 'apiV1' | 'apiV2' | 'app';
|
||||
|
||||
/**
|
||||
* The method of authentication used to access the API.
|
||||
*
|
||||
* If the request is not authenticated, the value will be `null`.
|
||||
*/
|
||||
auth: 'api' | 'session' | null;
|
||||
|
||||
/**
|
||||
* The user that is performing the action.
|
||||
*
|
||||
* If a team API key is used, the user will classified as the team.
|
||||
*/
|
||||
auditUser?: {
|
||||
id: number | null;
|
||||
email: string | null;
|
||||
name: string | null;
|
||||
};
|
||||
};
|
||||
|
||||
export const extractNextApiRequestMetadata = (req: NextApiRequest): RequestMetadata => {
|
||||
const parsedIp = ZIpSchema.safeParse(req.headers['x-forwarded-for'] || req.socket.remoteAddress);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user