mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ci fix
This commit is contained in:
1 parent
ce79bfab8b
commit
6b92b96225
4 files changed
+40
-2
No files matched your search
@@ -78,6 +78,7 @@ async function get(ctx: Context) {
|
||||
async function post(ctx: Context) {
|
||||
const {
|
||||
host, port, name, username, password,
|
||||
// @ts-expect-error
|
||||
} = ctx.request.body;
|
||||
let mongourl = 'mongodb://';
|
||||
if (username) mongourl += `${username}:${password}@`;
|
||||
|
||||
@@ -78,8 +78,9 @@ export function getSessionListByUid(uid: number) {
|
||||
return coll.find({ uid, tokenType: TYPE_SESSION }).sort('updateAt', -1).toArray();
|
||||
}
|
||||
|
||||
export function getMostRecentSessionByUid(uid: number) {
|
||||
return coll.findOne({ uid, tokenType: TYPE_SESSION }, { sort: { updateAt: -1 } });
|
||||
export async function getMostRecentSessionByUid(uid: number) {
|
||||
const res = await coll.find({ uid, tokenType: TYPE_SESSION }).sort('updateAt', -1);
|
||||
return res[0];
|
||||
}
|
||||
|
||||
export function delByUid(uid: number) {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Collection } from 'mongodb';
|
||||
import { Udoc } from '../interface';
|
||||
import * as db from '../service/db';
|
||||
import * as problem from '../model/problem';
|
||||
import { setPassword } from '../model/user';
|
||||
|
||||
export const description = 'Create A Test Database';
|
||||
|
||||
export async function run() {
|
||||
const collUser: Collection<Udoc> = db.collection('user');
|
||||
const collDocument = db.collection('document');
|
||||
await Promise.all([
|
||||
collUser.updateOne(
|
||||
{ _id: -1 },
|
||||
{
|
||||
priv: -1,
|
||||
uname: 'Root',
|
||||
unameLower: 'root',
|
||||
mail: 'root@hydro.local',
|
||||
mailLower: 'root@hydro.local',
|
||||
bio: 'Test Root User',
|
||||
regat: new Date(),
|
||||
loginat: new Date(),
|
||||
regip: '127.0.0.1',
|
||||
loginip: '127.0.0.1',
|
||||
},
|
||||
),
|
||||
]);
|
||||
await setPassword(-1, 'rootroot');
|
||||
}
|
||||
|
||||
export const validate = {};
|
||||
|
||||
global.Hydro.script.createTestDatabase = { run, description, validate };
|
||||
@@ -272,7 +272,9 @@ export class Handler {
|
||||
ip: ctx.request.ip,
|
||||
headers: ctx.request.headers,
|
||||
cookies: ctx.cookies,
|
||||
// @ts-ignore
|
||||
body: ctx.request.body,
|
||||
// @ts-ignore
|
||||
files: ctx.request.files,
|
||||
query: ctx.query,
|
||||
path: ctx.path,
|
||||
|
||||
Reference in new issue
Block a user