Skip to content

Commit

Permalink
count requests
Browse files Browse the repository at this point in the history
  • Loading branch information
InventivetalentDev committed Jun 8, 2024
1 parent 4e40007 commit 3ab9f84
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/database/schemas/Traffic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export const TrafficSchema: Schema<ITrafficDocument, ITrafficModel> = new Schema
lastRequest: {
type: Date,
expires: 3600
},
count: {
type: Number,
default: 0
}
},
{
Expand All @@ -32,7 +36,8 @@ TrafficSchema.statics.updateRequestTime = function (this: ITrafficModel, ip: str
ip: ip,
key: key
}, {
lastRequest: time
lastRequest: time,
$inc: {count: 1}
}, {upsert: true, maxTimeMS: 5000}).exec();
};

Expand Down

0 comments on commit 3ab9f84

Please sign in to comment.