feat: add logs and setup ejs templates
This commit is contained in:
parent
0904acb9a9
commit
622c59df4d
@ -3,11 +3,25 @@ import dotenv from 'dotenv';
|
|||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
|
import morgan from 'morgan';
|
||||||
|
import path from 'path';
|
||||||
|
import routes from './routes';
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const port = process.env.PORT ?? 3000;
|
const port = process.env.PORT ?? 3000;
|
||||||
|
|
||||||
|
const log_format = (process.env.NODE_ENV === "dev") ? "dev": "combined";
|
||||||
|
console.log("=== LOG CONFIG ===");
|
||||||
|
console.log(`log format: ${log_format}`);
|
||||||
|
console.log("=== END LOG CONFIG ===");
|
||||||
|
|
||||||
|
// Need the path.join for node to resolve correctly the templates directory
|
||||||
|
app.set('views', path.join(__dirname, 'templates'));
|
||||||
|
app.set('view engine', 'ejs');
|
||||||
|
|
||||||
|
// Add logs
|
||||||
|
app.use(morgan(log_format));
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(port, () => {
|
||||||
return console.log(`Express is listening at http://localhost:${port}`);
|
return console.log(`Briques is listening at http://localhost:${port}`);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user