Initial express.js project structure

This commit is contained in:
Gregory Ballantine 2022-11-01 23:55:07 -04:00
parent 53e0a557a3
commit 3c0ebc7001
5 changed files with 50 additions and 3 deletions

View File

@ -1,10 +1,17 @@
$nav-bar-height: 50px;
$primary-color: orange;
$primary-color-highlight: darken($primary-color, 10%);
$nav-bar-height: 60px;
body{
padding: $nav-bar-height 0 0;
background: lightgrey;
}
.container.fluid{
max-width: 100%;
}
#nav-bar{
position: fixed;
top: 0;
@ -13,6 +20,7 @@ body{
height: $nav-bar-height;
background: #212121;
box-shadow: 0 2px 1px rgba(0, 0, 0, .25);
color: white;
.nav-bar-left{
float: left;
@ -26,12 +34,22 @@ body{
}
}
.site-logo,
.nav-link a{
color: teal;
padding: 9px 12px;
font-size: 2.5rem;
}
.site-logo{
font-weight: bold;
}
.nav-link a{
color: $primary-color;
transition: all 230ms ease-in-out;
&:hover{
color: green;
color: $primary-color-highlight;
}
}
}

22
index.js Normal file
View File

@ -0,0 +1,22 @@
const express = require('express');
// instantiate new express.js app
const app = express();
const port = 3000;
// load the template engine
app.set('view engine', 'twig');
// enable static file serving
app.use(express.static('public'));
// load route handlers
const homeRoutes = require('./src/routes/home');
// register route handlers
app.get('/', homeRoutes.getIndex);
// start app
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});

View File

@ -4,6 +4,7 @@
"description": "Self-hosted inventory tracker",
"main": "index.js",
"scripts": {
"start": "node index.js",
"gulp": "gulp",
"test": "echo \"Error: no test specified\" && exit 1"
},

4
src/routes/home.js Normal file
View File

@ -0,0 +1,4 @@
// GET - /
exports.getIndex = function (req, res) {
res.render('index.twig');
};

View File

@ -1,5 +1,7 @@
{% extends 'layout.twig' %}
{% block title %}Home{% endblock %}
{% block content %}
<!-- page header -->