feat: encapsulate identity with better-auth
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Collection, type CollectionOptions, type Db, type Document, type MongoClient } from "mongodb";
|
||||
|
||||
import { container } from "./container.ts";
|
||||
import { mongo } from "./client.ts";
|
||||
|
||||
export function getDatabaseAccessor<TSchemas extends Record<string, Document>>(
|
||||
database: string,
|
||||
@@ -14,7 +14,7 @@ export function getDatabaseAccessor<TSchemas extends Record<string, Document>>(
|
||||
return instance;
|
||||
},
|
||||
get client(): MongoClient {
|
||||
return container.get("mongo");
|
||||
return mongo;
|
||||
},
|
||||
collection<TSchema extends keyof TSchemas>(
|
||||
name: TSchema,
|
||||
|
||||
4
platform/database/client.ts
Normal file
4
platform/database/client.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { config } from "./config.ts";
|
||||
import { getMongoClient } from "./connection.ts";
|
||||
|
||||
export const mongo = getMongoClient(config.mongo);
|
||||
@@ -1,6 +0,0 @@
|
||||
import { Container } from "@valkyr/inverse";
|
||||
import { MongoClient } from "mongodb";
|
||||
|
||||
export const container = new Container<{
|
||||
mongo: MongoClient;
|
||||
}>("@platform/database");
|
||||
@@ -1,9 +0,0 @@
|
||||
import { config } from "./config.ts";
|
||||
import { getMongoClient } from "./connection.ts";
|
||||
import { container } from "./container.ts";
|
||||
|
||||
export default {
|
||||
bootstrap: async (): Promise<void> => {
|
||||
container.set("mongo", getMongoClient(config.mongo));
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user