mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-11 00:08:37 +01:00
shields update
This commit is contained in:
18
shared_global/schema/shields/AddressBlacklistSchema.ts
Normal file
18
shared_global/schema/shields/AddressBlacklistSchema.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { model, Schema, Types } from 'mongoose';
|
||||
|
||||
export type TAddressBlacklistSchema = {
|
||||
_id: Schema.Types.ObjectId,
|
||||
project_id: Schema.Types.ObjectId,
|
||||
address: string,
|
||||
description: string,
|
||||
created_at: Date
|
||||
}
|
||||
|
||||
const AddressBlacklistSchema = new Schema<TAddressBlacklistSchema>({
|
||||
project_id: { type: Types.ObjectId, index: 1 },
|
||||
address: { type: String, required: true },
|
||||
description: { type: String },
|
||||
created_at: { type: Date, default: () => Date.now() },
|
||||
});
|
||||
|
||||
export const AddressBlacklistModel = model<TAddressBlacklistSchema>('address_blacklists', AddressBlacklistSchema);
|
||||
16
shared_global/schema/shields/DomainWhitelistSchema.ts
Normal file
16
shared_global/schema/shields/DomainWhitelistSchema.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { model, Schema, Types } from 'mongoose';
|
||||
|
||||
export type TDomainWhitelistSchema = {
|
||||
_id: Schema.Types.ObjectId,
|
||||
project_id: Schema.Types.ObjectId,
|
||||
domains: string[],
|
||||
created_at: Date
|
||||
}
|
||||
|
||||
const DomainWhitelistSchema = new Schema<TDomainWhitelistSchema>({
|
||||
project_id: { type: Types.ObjectId, index: 1 },
|
||||
domains: [{ type: String, required: true }],
|
||||
created_at: { type: Date, default: () => Date.now() },
|
||||
});
|
||||
|
||||
export const DomainWhitelistModel = model<TDomainWhitelistSchema>('domain_whitelists', DomainWhitelistSchema);
|
||||
@@ -9,7 +9,8 @@ const templateMap = {
|
||||
limit_90: '/limit/90',
|
||||
limit_max: '/limit/max',
|
||||
invite_project: '/invite',
|
||||
invite_project_noaccount: '/invite/noaccount'
|
||||
invite_project_noaccount: '/invite/noaccount',
|
||||
brevolist_add: '/brevolist/add'
|
||||
} as const;
|
||||
|
||||
export type EmailTemplate = keyof typeof templateMap;
|
||||
@@ -27,6 +28,7 @@ type EmailData =
|
||||
| { template: 'limit_max', data: { target: string, projectName: string } }
|
||||
| { template: 'invite_project', data: { target: string, projectName: string, link: string } }
|
||||
| { template: 'invite_project_noaccount', data: { target: string, projectName: string, link: string } }
|
||||
| { template: 'brevolist_add', data: { email: string } }
|
||||
|
||||
export class EmailService {
|
||||
static getEmailServerInfo<T extends EmailTemplate>(template: T, data: Extract<EmailData, { template: T }>['data']): EmailServerInfo {
|
||||
|
||||
@@ -26,6 +26,7 @@ export class RedisStreamService {
|
||||
|
||||
|
||||
private static METRICS_MAX_ENTRIES = 1000;
|
||||
private static METRICS_MAX_ENTRIES_PRODUCER = 1000;
|
||||
|
||||
static async METRICS_onProcess(id: string, time: number) {
|
||||
const key = `___dev_metrics`;
|
||||
@@ -39,6 +40,18 @@ export class RedisStreamService {
|
||||
return data.map(e => e.split(':')) as [string, string][];
|
||||
}
|
||||
|
||||
static async METRICS_PRODUCER_onProcess(id: string, time: number) {
|
||||
const key = `___dev_metrics_producer`;
|
||||
await this.client.lPush(key, `${id}:${time.toString()}`);
|
||||
await this.client.lTrim(key, 0, this.METRICS_MAX_ENTRIES_PRODUCER - 1);
|
||||
}
|
||||
|
||||
static async METRICS_PRODUCER_get() {
|
||||
const key = `___dev_metrics_producer`;
|
||||
const data = await this.client.lRange(key, 0, -1);
|
||||
return data.map(e => e.split(':')) as [string, string][];
|
||||
}
|
||||
|
||||
|
||||
static async connect() {
|
||||
await this.client.connect();
|
||||
|
||||
Reference in New Issue
Block a user