Boilerplate generator and deno tasks for monorepo

This commit is contained in:
Emma
2023-05-01 20:28:18 -06:00
parent a367562ba0
commit a910783882
36 changed files with 1164 additions and 47 deletions

16
lib/data.ts Normal file
View File

@@ -0,0 +1,16 @@
import mongoose from 'mongoose';
import { vault } from 'common/vault.ts';
/**
*
* @param dbName The Database to open
*/
export const configDatabase = async (mg: typeof mongoose, dbName = 'BattleLog') => {
if (!vault.get('MONGODB_URI')) throw 'No MongoDB URI, is your secrets file present and populated?'
await mg.connect(vault.getf('MONGODB_URI', { db: dbName })!)
}
export const openDatabase = async (mg: typeof mongoose, dbName = 'BattleLog') => {
if (!vault.get('MONGODB_URI')) throw 'No MongoDB URI, is your secrets file present and populated?'
return await mg.connect(vault.getf('MONGODB_URI', { db: dbName })!)
}