24 lines
917 B
TypeScript
24 lines
917 B
TypeScript
import mongoose, {CallbackError} from 'mongoose';
|
|
import * as api from './server/api';
|
|
import * as shortener from './server/shortener';
|
|
import * as contentDelivery from './server/contentDelivery';
|
|
import * as actionSocket from './server/actionSocket';
|
|
|
|
// Load & check environment
|
|
require('dotenv').config();
|
|
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 || ''));
|
|
shortener.startServer(parseInt(process.env.SHORTENER_PORT || ''));
|
|
contentDelivery.startServer(parseInt(process.env.CDN_PORT || ''));
|
|
actionSocket.startServer(parseInt(process.env.AS_PORT || ''));
|
|
} |