Integrated the database into the app.ts & added the start method
This commit is contained in:
parent
1aa963bdc9
commit
7dcc6a58d7
15
app.ts
15
app.ts
@ -1,3 +1,18 @@
|
|||||||
|
import mongoose, {CallbackError} from 'mongoose';
|
||||||
|
import * as api from './server/api';
|
||||||
|
|
||||||
// Load & check environment
|
// Load & check environment
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
require('./util/envCheck').validate();
|
require('./util/envCheck').validate();
|
||||||
|
|
||||||
|
// Connect to database
|
||||||
|
mongoose.connect(process.env.MONGOOSE_STRING || '', (e: CallbackError) => {
|
||||||
|
if (e) throw new Error(`Could not connect to database: ${e.message}`);
|
||||||
|
console.log("[DB] Successfully connected to the database");
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Start all servers
|
||||||
|
const start = () => {
|
||||||
|
api.startServer(parseInt(process.env.API_PORT || ''));
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user