mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00

* perf: qps limit * perf: http response data * perf: json path check * fix: ts * loop support reference parent variable
28 lines
606 B
TypeScript
28 lines
606 B
TypeScript
import { getMongoModel, Schema } from '../../mongo';
|
|
import type { FrequencyLimitSchemaType } from './type';
|
|
|
|
const FrequencyLimitSchema = new Schema({
|
|
eventId: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
amount: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
expiredTime: {
|
|
type: Date,
|
|
required: true
|
|
}
|
|
});
|
|
|
|
try {
|
|
FrequencyLimitSchema.index({ eventId: 1, expiredTime: 1 });
|
|
FrequencyLimitSchema.index({ expiredTime: 1 }, { expireAfterSeconds: 0 });
|
|
} catch (error) {}
|
|
|
|
export const MongoFrequencyLimit = getMongoModel<FrequencyLimitSchemaType>(
|
|
'frequency_limit',
|
|
FrequencyLimitSchema
|
|
);
|