2022-09-21 17:24:02 +02:00
|
|
|
import errorHandler from "errorhandler";
|
2022-09-27 23:38:40 +02:00
|
|
|
import "./env.js";
|
2022-09-21 17:24:02 +02:00
|
|
|
import app from "./app.js";
|
2022-09-27 23:38:40 +02:00
|
|
|
import logger from "./config/winston.js";
|
|
|
|
import postInit from "./postInit.js";
|
|
|
|
import figlet from "figlet";
|
|
|
|
import kleur from 'kleur';
|
2022-09-21 17:24:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Error Handler. Provides full stack
|
|
|
|
*/
|
|
|
|
if (process.env.NODE_ENV === "development") {
|
|
|
|
app.use(errorHandler());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start Express server.
|
|
|
|
*/
|
|
|
|
const server = app.listen(app.get("port"), () => {
|
2022-09-27 23:38:40 +02:00
|
|
|
console.log(kleur.yellow().bold(figlet.textSync("NC Backup")))
|
|
|
|
logger.info(
|
|
|
|
`App is running at ` + kleur.green().bold(`http://localhost:${app.get("port")}`) + " in " + kleur.green().bold(app.get("env")) + " mode"
|
2022-09-21 17:24:02 +02:00
|
|
|
);
|
2022-09-27 23:38:40 +02:00
|
|
|
logger.info(kleur.red().bold("Press CTRL-C to stop"));
|
|
|
|
postInit();
|
2022-09-21 17:24:02 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
export default server;
|