35 lines
917 B
TypeScript
35 lines
917 B
TypeScript
// app/models/web-token.ts
|
|
// Copyright (C) 2026 Robert Colbert <rob.colbert@openplatform.us>
|
|
// All Rights Reserved
|
|
|
|
import { Schema, Types, model } from "mongoose";
|
|
import { IUser } from "./user.js";
|
|
|
|
import { DtpLog } from "../lib/log.js";
|
|
const log = new DtpLog({
|
|
name: "WebTokenModel",
|
|
slug: "webToken",
|
|
});
|
|
|
|
export interface IWebToken {
|
|
_id: Types.ObjectId;
|
|
created: Date;
|
|
expires: Date;
|
|
user: IUser | Types.ObjectId;
|
|
token: string;
|
|
}
|
|
export const WebTokenSchema = new Schema<IWebToken>({
|
|
created: { type: Date, required: true, index: 1 },
|
|
expires: { type: Date, required: true, index: -1 },
|
|
user: { type: Schema.Types.ObjectId, required: true, ref: "User" },
|
|
token: { type: String, required: true },
|
|
});
|
|
|
|
export const WebToken = model<IWebToken>("WebToken", WebTokenSchema);
|
|
export default WebToken;
|
|
|
|
(async () => {
|
|
log.info("Syncing indexes...");
|
|
await WebToken.syncIndexes();
|
|
})();
|