交互式安装

This commit is contained in:
undefined committed 2020-05-10 13:18:53 +08:00
1 parent 6134a16f8c
commit 27cfe81e31
21 files changed
+333 -181

No files matched your search

+9 -1
View File
@@ -6,11 +6,19 @@ async function add(ip) {
const expireAt = new Date(new Date().getTime() + 365 * 24 * 60 * 60 * 1000);
return coll.findOneAndUpdate({ _id: ip }, { $set: { expireAt } }, { upsert: true });
}
function get(ip) {
return coll.findOne({ _id: ip });
}
function del(ip) {
return coll.deleteOne({ _id: ip });
}
module.exports = { add, get, del };
function index() {
return coll.createIndex('expireAt', { expireAfterSeconds: 0 });
}
module.exports = {
add, get, del, index,
};
+1 -1
View File
@@ -12,7 +12,7 @@ async function update(_id, operation, config) {
return get(_id);
}
async function set(_id, value) {
await coll.findOneAndUpdate({ _id }, { value }, { upsert: true });
await coll.findOneAndUpdate({ _id }, { $set: { value } }, { upsert: true });
return get(_id);
}
/**
+9
View File
@@ -3,12 +3,21 @@ const { ValidationError } = require('../error');
const coll = db.collection('token');
function index() {
return Promise.all([
coll.createIndex([{ uid: 1 }, { tokenType: 1 }, { updateAt: -1 }], { sparse: true }),
coll.createIndex('expireAt', { expireAfterSeconds: 0 }),
]);
}
module.exports = {
TYPE_SESSION: 0,
TYPE_CSRF_TOKEN: 1,
TYPE_REGISTER: 2,
TYPE_CHANGEMAIL: 3,
index,
/**
* Add a token.
* @param {number} tokenType type of the token.