mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: setup: fix database connection
This commit is contained in:
1 file changed
+3
-2
@@ -53,8 +53,9 @@ async function get(ctx: Context) {
|
||||
|
||||
async function post(ctx: Context) {
|
||||
try {
|
||||
const url = mongoUri.parse(ctx.request.body?.url);
|
||||
const Database = await MongoClient.connect((ctx.request as any).body, {
|
||||
if (!ctx.request.body?.url) throw new Error('no url found');
|
||||
const url = mongoUri.parse(ctx.request.body.url);
|
||||
const Database = await MongoClient.connect(ctx.request.body.url, {
|
||||
readPreference: 'nearest',
|
||||
writeConcern: new WriteConcern('majority'),
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user