Base project structure with express.js

This commit is contained in:
Gregory Ballantine 2021-09-03 19:12:54 -04:00
parent 3b6543ae19
commit e65b30edc1
7 changed files with 1659 additions and 2 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# ignore the node_modules directory since this can be automatically generated
node_modules/

View File

@ -1,3 +1,13 @@
# minecraft-website
# Bit Goblin <3 Minecraft
The source code for Bit Goblin's Minecraft info website
**This is not "Microsoft <3 Linux"... this is for real!**
The source code for Bit Goblin's Minecraft info website, built with express.js. I know the framework is rather old at this point, but who cares? It's stable and works well enough to serve a mostly static website.
Anyways, this is basically a simple website that displays the current Minecraft server info for the Bit Goblin community. This was originally made with Jekyll, but I had an idea for a cool little active players counter that required this be dynamically generated... or I could've used some javascript AJAX requests but no one wants that if it's not really necessary.
Feel free to clone this repository and get hacking on it! It's really nothing special but any help making the site better for the community or whatever will be greatly appreciated!
Featured in this repository are some scripts under `bin/` which will make your life easier if you wish to hack on this thing. Assuming your user has access to Docker, then you can simply run a `bin/docker-watch.sh` to get running with a simple node.js container that installs all dependencies and even watches for changes in the local directory (thank you nodemon!).
This code is open-source and available to all under the Apache license 2.0. All contributions to this codebase shall be made under the current license, and any future licenses this repository may change to. (e.g. if I decide to change to the BSD 2-Clause license, all code will then be under the BSD 2-Clause license)

1563
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

19
package.json Normal file
View File

@ -0,0 +1,19 @@
{
"name": "minecraft-website",
"description": "**This is not \"Microsoft <3 Linux\"... this is for real!**",
"version": "0.1.0",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "gitea@git.metaunix.net:bitgoblin/minecraft-website.git"
},
"author": "Gregory Ballantine <gballantine@bitgoblin.tech>",
"license": "Apache-2.0",
"dependencies": {
"express": "^4.17.1",
"pug": "^3.0.2"
}
}

3
routes/site.js Normal file
View File

@ -0,0 +1,3 @@
exports.index = function(req, res){
res.render('index');
};

24
server.js Normal file
View File

@ -0,0 +1,24 @@
const express = require('express');
const app = express();
const port = 3000;
// load routes
var siteRoutes = require('./routes/site');
// load template engine
app.set('views', './views');
app.set('view engine', 'pug');
// middleware
app.use((req, res, next) => {
console.log(`${req.method}: ${req.url}`);
next();
});
// register routes
app.get('/', siteRoutes.index);
// start the express.js server
app.listen(port, () => {
console.log(`Server started at port ${port}`);
});

36
views/index.pug Normal file
View File

@ -0,0 +1,36 @@
doctype=html
html
head
meta(name='viewport' content='width=device-width, initial-scale=1.0')
title Minecraft @ Bit Goblin
link(rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css')
link(rel='stylesheet' href='/css/camelot.css')
body
.container
header.row
.columns.twelve
img.u-max-full-width(src='https://i.imgur.com/XJQoBDx.png' alt='Minecraft java edition logo')
section.row
article.columns.twelve
h3 Server #1
table
tr
td Address
td mc1.bitgoblin.tech
tr
td Port
td 25565
tr
td Version
td 1.17.1
tr
td Mode
td Survival
tr
td Mods?
td None (Vanilla)
footer.row
.columns.twelve
p Hosted by Bit Goblin, with love.