Continued work on project infrastructure; added sequelize for database, added more layout in the views
This commit is contained in:
parent
092b7d8cc2
commit
0938eb1b03
2
.gitignore
vendored
2
.gitignore
vendored
@ -130,3 +130,5 @@ dist
|
|||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
|
# Local data files
|
||||||
|
data/*
|
||||||
|
0
data/.gitkeep
Normal file
0
data/.gitkeep
Normal file
20
index.js
20
index.js
@ -2,6 +2,26 @@ const express = require('express');
|
|||||||
const app = express();
|
const app = express();
|
||||||
const port = 3000;
|
const port = 3000;
|
||||||
|
|
||||||
|
// grab app and node.js process data
|
||||||
|
const pjson = require('./package.json');
|
||||||
|
const { versions } = require('node:process');
|
||||||
|
|
||||||
|
// register app and node.js versions with views;
|
||||||
|
app.locals.app_version = pjson.version;
|
||||||
|
app.locals.node_version = versions.node;
|
||||||
|
|
||||||
|
// initialize database
|
||||||
|
const sequelize = require('./src/models');
|
||||||
|
sequelize.sync({}).then(function(){
|
||||||
|
console.log('database has been synced');
|
||||||
|
}).catch(function(){
|
||||||
|
console.log('unable to sync database');
|
||||||
|
});
|
||||||
|
|
||||||
|
// enable sessions
|
||||||
|
const session = require("express-session");
|
||||||
|
app.use(session({ resave: true, secret: "123456", saveUninitialized: true }));
|
||||||
|
|
||||||
// enable the Twig template engine
|
// enable the Twig template engine
|
||||||
app.set('view engine', 'twig');
|
app.set('view engine', 'twig');
|
||||||
|
|
||||||
|
1357
package-lock.json
generated
1357
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
|
"express-session": "^1.17.3",
|
||||||
|
"sequelize": "^6.35.1",
|
||||||
|
"sqlite3": "^5.1.6",
|
||||||
"twig": "^1.16.0"
|
"twig": "^1.16.0"
|
||||||
},
|
},
|
||||||
"name": "leviathan",
|
"name": "leviathan",
|
||||||
|
10
src/models/index.js
Normal file
10
src/models/index.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const { Sequelize } = require('sequelize');
|
||||||
|
|
||||||
|
const sequelize = new Sequelize({
|
||||||
|
dialect: 'sqlite',
|
||||||
|
storage: 'data/leviathan.db'
|
||||||
|
});
|
||||||
|
|
||||||
|
const Project = require('./project')(sequelize);
|
||||||
|
|
||||||
|
module.exports = sequelize;
|
15
src/models/project.js
Normal file
15
src/models/project.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
const { Sequelize } = require("sequelize");
|
||||||
|
|
||||||
|
module.exports = (sequelize) => {
|
||||||
|
const Project = sequelize.define('Project', {
|
||||||
|
title: {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
null: false
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: Sequelize.TEXT,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{});
|
||||||
|
return Project;
|
||||||
|
};
|
@ -5,8 +5,16 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<title>{% block title %}{% endblock %} | Leviathan</title>
|
<title>{% block title %}{% endblock %} | Leviathan</title>
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" charset="utf-8"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
{% include 'partials/navbar.twig' %}
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% include 'partials/footer.twig' %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
4
views/partials/footer.twig
Normal file
4
views/partials/footer.twig
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<nav id="main-footer" class="container fluid">
|
||||||
|
<p>Leviathan version {{ app_version }}</p>
|
||||||
|
<p>Running node.js version {{ node_version }}</p>
|
||||||
|
</nav>
|
11
views/partials/navbar.twig
Normal file
11
views/partials/navbar.twig
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<nav id="main-nav">
|
||||||
|
<div class="nav-left">
|
||||||
|
<h4>Leviathan</h4>
|
||||||
|
<ul>
|
||||||
|
<li><a href="/">Dashboard</a></li>
|
||||||
|
<li><a href="/project">Projects</a></li>
|
||||||
|
<li><a href="/hardware">Hardware</a></li>
|
||||||
|
<li><a href="/benchmark">Benchmarks</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
Loading…
Reference in New Issue
Block a user