37 lines
833 B
TypeScript
37 lines
833 B
TypeScript
import './paths';
|
|
import Server from './framework/express/server';
|
|
import ip from 'ip';
|
|
import UserModel from './framework/mongo/user';
|
|
import { MongoClient } from 'mongodb';
|
|
import { Config } from './config';
|
|
import { exit, env } from 'process';
|
|
|
|
export type Services = {
|
|
userModel: UserModel;
|
|
};
|
|
|
|
const configFile = env.CONFIGFILE;
|
|
if (configFile === undefined) {
|
|
console.log('env var CONFIGFILE not set');
|
|
exit(1);
|
|
}
|
|
|
|
const config = new Config(configFile);
|
|
|
|
const mongo = new MongoClient(config.mongo.uri);
|
|
const db = mongo.db(config.mongo.dbName);
|
|
|
|
const services: Services = {
|
|
userModel: new UserModel(db),
|
|
};
|
|
|
|
const server = new Server(config.server, services);
|
|
|
|
server.start(() =>
|
|
console.log(
|
|
`Running on http://127.0.0.1:${config.server.port} http://${ip.address()}:${
|
|
config.server.port
|
|
}`,
|
|
),
|
|
);
|