Overriding APIs
#
Main interfaceinterface APIInterface { /* * Called to get the authorisation URL for the thirdparty sign-up/sign-in flow * * @method: GET * * @params: set it to undefined to disable the API. * provider * options: see APIOptions below * * @returns: "OK" and url on success */ authorisationUrlGET: | undefined | ((input: { provider: TypeProvider; options: APIOptions; }) => Promise<{ status: "OK"; url: string; }>);
/* * Called to sign-up a new user or sign-in an existing user * * @method: POST * * @params: set it to undefined to disable the API. * provider * code: authorisation code returned after using authorisation url * redirectURI: URI to direct to after successful sign-up/sign-in * options: see APIOptions below * * @returns: "OK": on successfully signing up or signing in the user * "NO_EMAIL_GIVEN_BY_PROVIDER": if thirdparty provider used in the API doesn't return email of the user * "FIELD_ERROR": if there is any field error during thirdparty signup/signin flow */ signInUpPOST: | undefined | ((input: { provider: TypeProvider; code: string; redirectURI: string; options: APIOptions; }) => Promise< | { status: "OK"; createdNewUser: boolean; user: User; authCodeResponse: any; } | { status: "NO_EMAIL_GIVEN_BY_PROVIDER" } | { status: "FIELD_ERROR"; error: string; } >);}
#
Supporting Types- Express
- Hapi
- Fastify
- Koa
- Loopback
- AWS Lambda / Netlify
- Next.js
- NestJS
interface BaseRequest { original: Express.Request; getKeyValueFromQuery: (key: string) => Promise<string | undefined>; getJSONBody: () => Promise<any>; getMethod: () => HTTPMethod; getCookieValue: (key_: string) => string | undefined; getHeaderValue: (key: string) => string | undefined; getOriginalURL: () => string;}
interface BaseResponse { original: Express.Response; setHeader: (key: string, value: string, allowDuplicateKey: boolean) => void; setCookie: ( key: string, value: string, domain: string | undefined, secure: boolean, httpOnly: boolean, expires: number, path: string, sameSite: "strict" | "lax" | "none" ) => void; setStatusCode: (statusCode: number) => void; sendJSONResponse: (content: any) => void;}
interface BaseRequest { original: Hapi.Request; getKeyValueFromQuery: (key: string) => Promise<string | undefined>; getJSONBody: () => Promise<any>; getMethod: () => HTTPMethod; getCookieValue: (key_: string) => string | undefined; getHeaderValue: (key: string) => string | undefined; getOriginalURL: () => string;}
interface BaseResponse { original: Hapi.ResponseToolkit; setHeader: (key: string, value: string, allowDuplicateKey: boolean) => void; setCookie: ( key: string, value: string, domain: string | undefined, secure: boolean, httpOnly: boolean, expires: number, path: string, sameSite: "strict" | "lax" | "none" ) => void; setStatusCode: (statusCode: number) => void; sendJSONResponse: (content: any) => void;}
interface BaseRequest { original: Fastify.FastifyRequest; getKeyValueFromQuery: (key: string) => Promise<string | undefined>; getJSONBody: () => Promise<any>; getMethod: () => HTTPMethod; getCookieValue: (key_: string) => string | undefined; getHeaderValue: (key: string) => string | undefined; getOriginalURL: () => string;}
interface BaseResponse { original: Fastify.FastifyReply; setHeader: (key: string, value: string, allowDuplicateKey: boolean) => void; setCookie: ( key: string, value: string, domain: string | undefined, secure: boolean, httpOnly: boolean, expires: number, path: string, sameSite: "strict" | "lax" | "none" ) => void; setStatusCode: (statusCode: number) => void; sendJSONResponse: (content: any) => void;}
interface BaseRequest { original: AWS.APIGatewayProxyEvent | AWS.APIGatewayProxyEventV2; getKeyValueFromQuery: (key: string) => Promise<string | undefined>; getJSONBody: () => Promise<any>; getMethod: () => HTTPMethod; getCookieValue: (key_: string) => string | undefined; getHeaderValue: (key: string) => string | undefined; getOriginalURL: () => string;}
interface BaseResponse { original: AWS.APIGatewayProxyEvent | AWS.APIGatewayProxyEventV2; setHeader: (key: string, value: string, allowDuplicateKey: boolean) => void; setCookie: ( key: string, value: string, domain: string | undefined, secure: boolean, httpOnly: boolean, expires: number, path: string, sameSite: "strict" | "lax" | "none" ) => void; setStatusCode: (statusCode: number) => void; sendJSONResponse: (content: any) => void;}
interface BaseRequest { original: Koa.Context; getKeyValueFromQuery: (key: string) => Promise<string | undefined>; getJSONBody: () => Promise<any>; getMethod: () => HTTPMethod; getCookieValue: (key_: string) => string | undefined; getHeaderValue: (key: string) => string | undefined; getOriginalURL: () => string;}
interface BaseResponse { original: Koa.Context; setHeader: (key: string, value: string, allowDuplicateKey: boolean) => void; setCookie: ( key: string, value: string, domain: string | undefined, secure: boolean, httpOnly: boolean, expires: number, path: string, sameSite: "strict" | "lax" | "none" ) => void; setStatusCode: (statusCode: number) => void; sendJSONResponse: (content: any) => void;}
interface BaseRequest { original: Loopback.MiddlewareContext; getKeyValueFromQuery: (key: string) => Promise<string | undefined>; getJSONBody: () => Promise<any>; getMethod: () => HTTPMethod; getCookieValue: (key_: string) => string | undefined; getHeaderValue: (key: string) => string | undefined; getOriginalURL: () => string;}
interface BaseResponse { original: Loopback.MiddlewareContext; setHeader: (key: string, value: string, allowDuplicateKey: boolean) => void; setCookie: ( key: string, value: string, domain: string | undefined, secure: boolean, httpOnly: boolean, expires: number, path: string, sameSite: "strict" | "lax" | "none" ) => void; setStatusCode: (statusCode: number) => void; sendJSONResponse: (content: any) => void;}
interface BaseRequest { original: Next.NextApiRequest; getKeyValueFromQuery: (key: string) => Promise<string | undefined>; getJSONBody: () => Promise<any>; getMethod: () => HTTPMethod; getCookieValue: (key_: string) => string | undefined; getHeaderValue: (key: string) => string | undefined; getOriginalURL: () => string;}
interface BaseResponse { original: Next.NextApiResponse; setHeader: (key: string, value: string, allowDuplicateKey: boolean) => void; setCookie: ( key: string, value: string, domain: string | undefined, secure: boolean, httpOnly: boolean, expires: number, path: string, sameSite: "strict" | "lax" | "none" ) => void; setStatusCode: (statusCode: number) => void; sendJSONResponse: (content: any) => void;}
interface BaseRequest { // NestJS uses library-specific types for Request and Response // You should use the one provided by your underlying framework (the default is Express) original: Express.Request; getKeyValueFromQuery: (key: string) => Promise<string | undefined>; getJSONBody: () => Promise<any>; getMethod: () => HTTPMethod; getCookieValue: (key_: string) => string | undefined; getHeaderValue: (key: string) => string | undefined; getOriginalURL: () => string;}
interface BaseResponse { // NestJS uses library-specific types for Request and Response // You should use the one provided by your underlying framework (the default is Express) original: Express.Response; setHeader: (key: string, value: string, allowDuplicateKey: boolean) => void; setCookie: ( key: string, value: string, domain: string | undefined, secure: boolean, httpOnly: boolean, expires: number, path: string, sameSite: "strict" | "lax" | "none" ) => void; setStatusCode: (statusCode: number) => void; sendJSONResponse: (content: any) => void;}
interface APIOptions { recipeImplementation: RecipeInterface; config: TypeNormalisedInput; recipeId: string; isInServerlessEnv: boolean; providers: TypeProvider[]; req: BaseRequest; res: BaseResponse;}
interface TypeProvider { id: string; get: (redirectURI: string | undefined, authCodeFromRequest: string | undefined) => Promise<TypeProviderGetResponse>;}