core: setup: fix database connection

This commit is contained in:
undefined committed 2024-03-26 11:14:17 +08:00
1 parent 6ddbc8d0a7
commit fe0af5e6e8
1 file changed
+3 -2
+3 -2
View File
@@ -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'),
});