Files
rxminder/types/express.d.ts

29 lines
871 B
TypeScript

/**
* Express Request type augmentation
*
* Adds a `user` property to `Express.Request` to store authenticated user
* information attached by authentication middleware.
*
* The `user` shape is flexible to accommodate different token verification
* outputs. When using our JWT-based middleware, it will typically match
* `TokenPayload`, but we also allow `string` or a generic record for
* compatibility with other strategies.
*/
import type { TokenPayload } from '../services/auth/auth.types';
declare global {
namespace Express {
interface Request {
/**
* Authenticated user payload attached by middleware.
* - Usually matches TokenPayload in this project.
* - May be a string or a generic object when using different verifiers.
*/
user?: TokenPayload | string | Record<string, unknown>;
}
}
}
export {};