1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-08 23:10:05 +00:00

fix: added db seed at server startup

This commit is contained in:
Saad Jutt
2022-04-19 23:25:05 +05:00
parent c7ffde1a3b
commit 2e63831b90
5 changed files with 42 additions and 3 deletions

View File

@@ -1,7 +1,8 @@
import mongoose from 'mongoose'
import { populateClients } from '../routes/api/auth'
import { seedDB } from './seedDB'
export const connectDB = async () => {
export const connectDB = () => {
// NOTE: when exporting app.js as agent for supertest
// we should exclude connecting to the real database
if (process.env.NODE_ENV === 'test') {
@@ -19,6 +20,8 @@ export const connectDB = async () => {
console.log('Connected to db!')
await seedDB()
await populateClients()
})
}