forked from Yara724/api
25 lines
927 B
TypeScript
25 lines
927 B
TypeScript
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
|
import { HydratedDocument } from "mongoose";
|
|
import type { FanavaranClientKey } from "src/core/config/fanavaran-client.config";
|
|
|
|
/**
|
|
* Shared Fanavaran authenticationToken per tenant.
|
|
* Survives process restarts / multi-instance so we do not Login on every request.
|
|
*/
|
|
@Schema({ collection: "fanavaranAuthTokens", timestamps: true })
|
|
export class FanavaranAuthToken {
|
|
@Prop({ type: String, required: true, unique: true, index: true })
|
|
clientKey: FanavaranClientKey;
|
|
|
|
@Prop({ type: String, required: true })
|
|
authenticationToken: string;
|
|
|
|
/** When this token should be refreshed (Asia/Tehran midnight). */
|
|
@Prop({ type: Date, required: true, index: true })
|
|
expiresAt: Date;
|
|
}
|
|
|
|
export type FanavaranAuthTokenDocument = HydratedDocument<FanavaranAuthToken>;
|
|
export const FanavaranAuthTokenSchema =
|
|
SchemaFactory.createForClass(FanavaranAuthToken);
|