33 lines
713 B
JavaScript
33 lines
713 B
JavaScript
import initLog from '../utills/log.js'
|
|
import mongoose from 'mongoose'
|
|
import sqlite3 from 'sqlite3'
|
|
import { open } from 'sqlite'
|
|
|
|
const log = initLog("database")
|
|
|
|
export let sqlite = undefined
|
|
|
|
/**
|
|
* This initializes both the sqlite db and mongodb.
|
|
* @module libs/database/init
|
|
*/
|
|
async function init() {
|
|
log("Starting up databases...")
|
|
|
|
sqlite = await open({
|
|
filename: 'ddnet.sqlite',
|
|
driver: sqlite3.cached.Database
|
|
})
|
|
log("Loaded in 'ddnet.sqlite'!")
|
|
|
|
|
|
await mongoose.connect(
|
|
process.env.MONGO_URI,
|
|
{
|
|
useNewUrlParser: true,
|
|
useUnifiedTopology: true
|
|
}
|
|
).then(() => log("Connected to mongodb!"))
|
|
}
|
|
|
|
export default init |