initial config

This commit is contained in:
cv
2021-05-12 22:21:50 +02:00
parent 9e82062158
commit 152b2fc838
4 changed files with 50 additions and 3 deletions
+1
View File
@@ -32,3 +32,4 @@ server/db.json
yarn.lock
package.json
package-lock.json
db.json
+33
View File
@@ -0,0 +1,33 @@
const { app, BrowserWindow } = require('electron');
const path = require('path');
const nodeapp = require('./server/app.js');
function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
},
});
win.loadURL('http://localhost:4001/editor');
win.webContents.openDevTools();
}
app.whenReady().then(() => {
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
+10
View File
@@ -0,0 +1,10 @@
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector);
if (element) element.innerText = text;
};
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type]);
}
});
+6 -3
View File
@@ -13,6 +13,7 @@ const express = require('express');
const http = require('http');
const cors = require('cors');
const { dbModel } = require('./data/dataModel.js');
const path = require('path');
db.defaults(dbModel).write();
@@ -48,9 +49,11 @@ app.use(express.json());
app.use('/events', eventsRouter);
app.use('/event', eventRouter);
// implement general router
app.get('/', (req, res) => {
res.send('ontime API');
// serve react
app.use(express.static(path.join(__dirname, '../client/build')));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, '../client', 'build', 'index.html'));
});
// Implement route for errors