feat(server): add model base (#9734)

This commit is contained in:
forehalo
2025-01-17 02:03:53 +00:00
parent c2149f218b
commit 64335b9e0c
12 changed files with 105 additions and 65 deletions

View File

@@ -1,9 +1,10 @@
import { randomUUID } from 'node:crypto';
import { Injectable, Logger } from '@nestjs/common';
import { PrismaClient, type VerificationToken } from '@prisma/client';
import { Injectable } from '@nestjs/common';
import { type VerificationToken } from '@prisma/client';
import { CryptoHelper } from '../base/helpers';
import { BaseModel } from './base';
export type { VerificationToken };
@@ -16,12 +17,10 @@ export enum TokenType {
}
@Injectable()
export class VerificationTokenModel {
private readonly logger = new Logger(VerificationTokenModel.name);
constructor(
private readonly db: PrismaClient,
private readonly crypto: CryptoHelper
) {}
export class VerificationTokenModel extends BaseModel {
constructor(private readonly crypto: CryptoHelper) {
super();
}
/**
* create token by type and credential (optional) with ttl in seconds (default 30 minutes)