vk-stt-bot/src/app.ts

41 lines
1.0 KiB
TypeScript
Raw Normal View History

2020-02-15 19:07:55 +03:00
import "reflect-metadata";
import express from "express";
import config from "./config";
import Logger from "./loaders/logger";
import { BotMode } from "./interfaces/IConfig";
async function startServer() {
const app = express();
/**
* A little hack here
* Import/Export can only be used in 'top-level code'
* Well, at least in node 10 without babel and at the time of writing
* So we are using good old require.
**/
await require("./loaders").default({ expressApp: app });
app.listen(config.port, err => {
if (err) {
Logger.error(err);
process.exit(1);
return;
}
Logger.info(`
################################################
🛡 Server listening on port: ${config.port} 🛡
################################################
`);
});
}
async function startPoller() {
throw new Error("longpolling is not implemented yet");
}
if (config.botMode == BotMode.MODE_WEBHOOK) {
startServer();
} else {
startPoller();
}