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) {
|
async function post(ctx: Context) {
|
||||||
const {
|
const {
|
||||||
host, port, name, username, password,
|
host, port, name, username, password,
|
||||||
|
// @ts-expect-error
|
||||||
} = ctx.request.body;
|
} = ctx.request.body;
|
||||||
let mongourl = 'mongodb://';
|
let mongourl = 'mongodb://';
|
||||||
if (username) mongourl += `${username}:${password}@`;
|
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();
|
return coll.find({ uid, tokenType: TYPE_SESSION }).sort('updateAt', -1).toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getMostRecentSessionByUid(uid: number) {
|
export async function getMostRecentSessionByUid(uid: number) {
|
||||||
return coll.findOne({ uid, tokenType: TYPE_SESSION }, { sort: { updateAt: -1 } });
|
const res = await coll.find({ uid, tokenType: TYPE_SESSION }).sort('updateAt', -1);
|
||||||
|
return res[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function delByUid(uid: number) {
|
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,
|
ip: ctx.request.ip,
|
||||||
headers: ctx.request.headers,
|
headers: ctx.request.headers,
|
||||||
cookies: ctx.cookies,
|
cookies: ctx.cookies,
|
||||||
|
// @ts-ignore
|
||||||
body: ctx.request.body,
|
body: ctx.request.body,
|
||||||
|
// @ts-ignore
|
||||||
files: ctx.request.files,
|
files: ctx.request.files,
|
||||||
query: ctx.query,
|
query: ctx.query,
|
||||||
path: ctx.path,
|
path: ctx.path,
|
||||||
|
|||||||
Reference in new issue
Block a user