MCPcopy Create free account
hub / github.com/esmBot/esmBot / init

Function init

src/database.ts:31–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29}
30
31export async function init(): Promise<DatabasePlugin | undefined> {
32 if (process.env.DB && process.env.DB.length !== 0) {
33 const dbtype = process.env.DB.split("://")[0];
34 try {
35 const construct = (await import(`./database/${dbtype}.${detectRuntime().tsLoad ? "ts" : "js"}`)).default;
36 return new construct(process.env.DB);
37 } catch (error) {
38 if (isError(error) && error.code === "ERR_MODULE_NOT_FOUND") {
39 logger.error(`DB config option has unknown database type '${dbtype}'`);
40 }
41 throw error;
42 }
43 } else {
44 logger.warn("No database configured, running in stateless mode...");
45 return;
46 }
47}

Callers

nothing calls this directly

Calls 2

detectRuntimeFunction · 0.85
isErrorFunction · 0.85

Tested by

no test coverage detected