- Server now set up to allow local access without password

- Svelte side built using latest version of svelte and rollup
This commit is contained in:
Martin Donnelly 2021-08-30 10:04:11 +01:00
parent e98342cca0
commit b91c1784cb
8 changed files with 15 additions and 34 deletions

View File

@ -1,4 +1 @@
.filterBar.svelte-17lzm0a{background:var(--medium-color);margin-bottom:1rem;padding:10px 5px}
.recipeItem.svelte-qibu9a{display:flex;padding:0.1rem;border-bottom:1px #ccc dotted}.recipeItem.svelte-qibu9a:nth-of-type(odd){background-color:rgba(0, 0, 0, 0.04)}.listItemSix.svelte-qibu9a{flex:6}.listItemThree.svelte-qibu9a{flex:3}.chicken.svelte-qibu9a{background:#8e5241;color:#fff}.beef.svelte-qibu9a{background:#d72414;color:#fff}.pork.svelte-qibu9a{background:#ef96d9;color:#fff}.fish.svelte-qibu9a{background:#005ba0;color:#fff}.egg.svelte-qibu9a{background:#fbc003;color:#000}.vegetable.svelte-qibu9a{background:#00903e;color:#fff}
/*# sourceMappingURL=bundle.css.map */
.filterBar.svelte-17lzm0a{background:var(--medium-color);margin-bottom:1rem;padding:10px 5px}.recipeItem.svelte-qibu9a{display:flex;padding:0.1rem;border-bottom:1px #ccc dotted}.recipeItem.svelte-qibu9a:nth-of-type(odd){background-color:rgba(0, 0, 0, 0.04)}.listItemSix.svelte-qibu9a{flex:6}.listItemThree.svelte-qibu9a{flex:3}.chicken.svelte-qibu9a{background:#8e5241;color:#fff}.beef.svelte-qibu9a{background:#d72414;color:#fff}.pork.svelte-qibu9a{background:#ef96d9;color:#fff}.fish.svelte-qibu9a{background:#005ba0;color:#fff}.egg.svelte-qibu9a{background:#fbc003;color:#000}.vegetable.svelte-qibu9a{background:#00903e;color:#fff}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

0
dist/favicon.png vendored Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

0
live/favicon.ico Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 318 B

0
live/gfx/recipes.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

0
menu.db Normal file → Executable file
View File

View File

@ -1,3 +1,4 @@
'use strict';
require('dotenv').config();
const express = require('express');
const bodyParser = require('body-parser');
@ -5,60 +6,48 @@ const session = require('express-session');
const path = require('path');
const helmet = require('helmet');
const cors = require('cors');
const cron = require('node-cron');
const db = require('./server/lib/loginmanager');
const doJob = require('./server/lib/job');
const checkAuth = require('./server/middle/checkAuth');
// create express app
const app = express();
require('dotenv').config();
const serverPort = process.env.PORT || 3000;
const localHost = process.env.LOCAL || false;
const sitePath = 'dist';
app.use(cors());
app.use(helmet());
app.use(session({
'secret': 'rBLH5#Q89Z4',
'resave': true,
'saveUninitialized': true
}));
app.get('/', (request, response) => {
if (request.session.auth)
response.redirect('/menu');
else
if (!localHost)
response.sendFile(path.join(`${__dirname}/server/static/login.html`));
else {
// fix auth.
request.session.username = 'martin';
request.session.auth = 'jhgkjgkjhgkjhgjkhgjkhgfhghfjgfjhgf';
response.redirect('/menu');
}
});
app.get('/menu', checkAuth, (req, res) => {
res.sendFile(path.join(`${__dirname }/dist/index.html`));
res.sendFile(path.join(`${__dirname}/dist/index.html`));
});
app.use(express.static(path.join(__dirname, sitePath)));
// parse requests of content-type - application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ 'extended': true }));
// parse requests of content-type - application/json
app.use(bodyParser.json());
app.post('/auth', (request, response) => {
const username = request.body.u;
const password = request.body.p;
if (username && password)
db.getOne(username, password)
.then((data) => {
if (!data)
// response.send('Incorrect Username and/or Password!');
response.redirect('/');
else {
request.session.username = username;
@ -72,25 +61,19 @@ app.post('/auth', (request, response) => {
'message': err.message || 'Some error occurred while querying the database.'
});
});
else {
response.send('Please enter Username and Password!');
response.end();
}
});
require('./server/routes/recipe.routes')(app);
require('./server/routes/view.routes')(app);
// listen for requests
app.listen(serverPort, () => {
console.log(`Server is listening on port ${serverPort}`);
});
((() => {
console.log('Menuserver 2.0 started');
})());
cron.schedule('0 8 * * 6', function () {
doJob();