mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
update interface.ts
This commit is contained in:
1 parent
10956f1fee
commit
d4e849a133
8 files changed
+99
-71
No files matched your search
@@ -1,13 +1,19 @@
|
||||
import * as db from '../service/db';
|
||||
import { Bdoc } from '../interface';
|
||||
|
||||
const coll = db.collection('blacklist');
|
||||
|
||||
export async function add(ip: string) {
|
||||
export async function add(ip: string): Promise<Bdoc> {
|
||||
const expireAt = new Date(new Date().getTime() + 365 * 24 * 60 * 60 * 1000);
|
||||
return coll.findOneAndUpdate({ _id: ip }, { $set: { expireAt } }, { upsert: true });
|
||||
const res = await coll.findOneAndUpdate(
|
||||
{ _id: ip },
|
||||
{ $set: { expireAt } },
|
||||
{ upsert: true, returnOriginal: false },
|
||||
);
|
||||
return res.value;
|
||||
}
|
||||
|
||||
export function get(ip: string) {
|
||||
export function get(ip: string): Promise<Bdoc> {
|
||||
return coll.findOne({ _id: ip });
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user