diff --git a/app.js b/app.js index ab78f0a..0ba661c 100644 --- a/app.js +++ b/app.js @@ -7,7 +7,7 @@ app.use('/third_party', express.static('third_party')) // BodyParser app.use(express.urlencoded({ extended: true })) - +// CookieParser const cookieParser = require('cookie-parser') app.use(cookieParser()) @@ -25,6 +25,8 @@ app.engine('hbs', exphbs({ // Routes require('./app/routes/routes')(app) +// Open in browser +const open = require('open') const webserverPort = 3000 const webserver = () => { @@ -33,7 +35,13 @@ const webserver = () => { console.log(`\x1b[1m\x1b[2m[WEBSERVER] - \x1b[0m\x1b[1m\x1b[31m\x1b[5mFAILED\x1b[0m\x1b[31m: Unable to bind to port 5000. Could there possibly be another instance alive?\x1b[0m`) process.exit(1) } - console.log(`\x1b[1m\x1b[2m[WEBSERVER] - \x1b[1m\x1b[34mOK\x1b[0m: Webserver binded on port ${webserverPort} | http://localhost:${webserverPort}\x1b[0m`) + // console.log(`\x1b[1m\x1b[2m[WEBSERVER] - \x1b[1m\x1b[34mOK\x1b[0m: Webserver binded on port ${webserverPort} | http://localhost:${webserverPort}\x1b[0m`) + console.log(`${chalk.greenBright('Loaded and ready: ')}${chalk.whiteBright('Launching Metronami in your browser...')}`) + open(`http://localhost:${webserverPort}`) + + setTimeout(() => { + console.log(`${chalk.cyan('Nothing happened? ')}${chalk.whiteBright('You may manually access Metronami at http://localhost:' + webserverPort)}`) + }, 5000) }) }