- 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:
parent
e98342cca0
commit
b91c1784cb
5
dist/build/bundle.css
vendored
5
dist/build/bundle.css
vendored
@ -1,4 +1 @@
|
|||||||
.filterBar.svelte-17lzm0a{background:var(--medium-color);margin-bottom:1rem;padding:10px 5px}
|
.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}
|
||||||
.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 */
|
|
3
dist/build/bundle.js
vendored
3
dist/build/bundle.js
vendored
File diff suppressed because one or more lines are too long
2
dist/build/bundle.js.map
vendored
2
dist/build/bundle.js.map
vendored
File diff suppressed because one or more lines are too long
0
dist/favicon.png
vendored
Normal file → Executable file
0
dist/favicon.png
vendored
Normal file → Executable file
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
0
live/favicon.ico
Normal file → Executable file
0
live/favicon.ico
Normal file → Executable file
Before Width: | Height: | Size: 318 B After Width: | Height: | Size: 318 B |
0
live/gfx/recipes.png
Normal file → Executable file
0
live/gfx/recipes.png
Normal file → Executable file
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
39
server.js
39
server.js
@ -1,3 +1,4 @@
|
|||||||
|
'use strict';
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
@ -5,60 +6,48 @@ const session = require('express-session');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const helmet = require('helmet');
|
const helmet = require('helmet');
|
||||||
const cors = require('cors');
|
const cors = require('cors');
|
||||||
|
|
||||||
const cron = require('node-cron');
|
const cron = require('node-cron');
|
||||||
|
|
||||||
const db = require('./server/lib/loginmanager');
|
const db = require('./server/lib/loginmanager');
|
||||||
|
|
||||||
const doJob = require('./server/lib/job');
|
const doJob = require('./server/lib/job');
|
||||||
const checkAuth = require('./server/middle/checkAuth');
|
const checkAuth = require('./server/middle/checkAuth');
|
||||||
|
|
||||||
// create express app
|
|
||||||
const app = express();
|
const app = express();
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
|
|
||||||
const serverPort = process.env.PORT || 3000;
|
const serverPort = process.env.PORT || 3000;
|
||||||
|
const localHost = process.env.LOCAL || false;
|
||||||
const sitePath = 'dist';
|
const sitePath = 'dist';
|
||||||
|
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
app.use(helmet());
|
app.use(helmet());
|
||||||
|
|
||||||
app.use(session({
|
app.use(session({
|
||||||
'secret': 'rBLH5#Q89Z4',
|
'secret': 'rBLH5#Q89Z4',
|
||||||
'resave': true,
|
'resave': true,
|
||||||
'saveUninitialized': true
|
'saveUninitialized': true
|
||||||
}));
|
}));
|
||||||
|
|
||||||
app.get('/', (request, response) => {
|
app.get('/', (request, response) => {
|
||||||
if (request.session.auth)
|
if (request.session.auth)
|
||||||
response.redirect('/menu');
|
response.redirect('/menu');
|
||||||
else
|
else
|
||||||
|
if (!localHost)
|
||||||
response.sendFile(path.join(`${__dirname}/server/static/login.html`));
|
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) => {
|
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)));
|
app.use(express.static(path.join(__dirname, sitePath)));
|
||||||
|
|
||||||
// parse requests of content-type - application/x-www-form-urlencoded
|
|
||||||
app.use(bodyParser.urlencoded({ 'extended': true }));
|
app.use(bodyParser.urlencoded({ 'extended': true }));
|
||||||
|
|
||||||
// parse requests of content-type - application/json
|
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
|
|
||||||
app.post('/auth', (request, response) => {
|
app.post('/auth', (request, response) => {
|
||||||
const username = request.body.u;
|
const username = request.body.u;
|
||||||
const password = request.body.p;
|
const password = request.body.p;
|
||||||
|
|
||||||
if (username && password)
|
if (username && password)
|
||||||
|
|
||||||
db.getOne(username, password)
|
db.getOne(username, password)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (!data)
|
if (!data)
|
||||||
// response.send('Incorrect Username and/or Password!');
|
|
||||||
response.redirect('/');
|
response.redirect('/');
|
||||||
else {
|
else {
|
||||||
request.session.username = username;
|
request.session.username = username;
|
||||||
@ -72,25 +61,19 @@ app.post('/auth', (request, response) => {
|
|||||||
'message': err.message || 'Some error occurred while querying the database.'
|
'message': err.message || 'Some error occurred while querying the database.'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
else {
|
else {
|
||||||
response.send('Please enter Username and Password!');
|
response.send('Please enter Username and Password!');
|
||||||
response.end();
|
response.end();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
require('./server/routes/recipe.routes')(app);
|
require('./server/routes/recipe.routes')(app);
|
||||||
require('./server/routes/view.routes')(app);
|
require('./server/routes/view.routes')(app);
|
||||||
|
|
||||||
// listen for requests
|
|
||||||
app.listen(serverPort, () => {
|
app.listen(serverPort, () => {
|
||||||
console.log(`Server is listening on port ${serverPort}`);
|
console.log(`Server is listening on port ${serverPort}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
((() => {
|
((() => {
|
||||||
console.log('Menuserver 2.0 started');
|
console.log('Menuserver 2.0 started');
|
||||||
})());
|
})());
|
||||||
|
|
||||||
cron.schedule('0 8 * * 6', function () {
|
cron.schedule('0 8 * * 6', function () {
|
||||||
doJob();
|
doJob();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user