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{ body{
padding: $nav-bar-height 0 0; padding: $nav-bar-height 0 0;
background: lightgrey; background: lightgrey;
} }
.container.fluid{
max-width: 100%;
}
#nav-bar{ #nav-bar{
position: fixed; position: fixed;
top: 0; top: 0;
@ -13,6 +20,7 @@ body{
height: $nav-bar-height; height: $nav-bar-height;
background: #212121; background: #212121;
box-shadow: 0 2px 1px rgba(0, 0, 0, .25); box-shadow: 0 2px 1px rgba(0, 0, 0, .25);
color: white;
.nav-bar-left{ .nav-bar-left{
float: left; float: left;
@ -26,12 +34,22 @@ body{
} }
} }
.site-logo,
.nav-link a{ .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; transition: all 230ms ease-in-out;
&:hover{ &: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", "description": "Self-hosted inventory tracker",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "node index.js",
"gulp": "gulp", "gulp": "gulp",
"test": "echo \"Error: no test specified\" && exit 1" "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' %} {% extends 'layout.twig' %}
{% block title %}Home{% endblock %}
{% block content %} {% block content %}
<!-- page header --> <!-- page header -->