connect fn update

This commit is contained in:
tmshv committed 2019-08-01 17:10:50 +03:00
1 parent 43af2996bf
commit 0713bad871
14 files changed
+16 -26

No files matched your search

-1
View File
@@ -1,7 +1,6 @@
import path from 'path'
export const port = process.env['PORT'] || 3000
export const dbUri = process.env['DB_URI'] || 'mongodb://mongo/hudozka'
export const name = 'Hudozka'
export const host = 'art.shlisselburg.org'
+4 -2
View File
@@ -6,13 +6,15 @@ const Teacher = require('./Teacher')
const Document = require('./Document')
const Image = require('./Image')
const Settings = require('./Config')
const getConfig = require('next/config').default
const { MongoClient, ObjectId } = require('mongodb')
var db
async function connect(uri) {
const connection = await MongoClient.connect(uri)
async function connect() {
const mongoUri = getConfig().serverRuntimeConfig.dbUri
const connection = await MongoClient.connect(mongoUri)
db = init(connection)
return db
}
+1 -1
View File
@@ -11,7 +11,7 @@ const port = parseInt(process.env.PORT, 10) || 3000
app.prepare().then(async () => {
try {
await connect(process.env.DB_URI)
await connect()
} catch (e) {
console.error(e.message)