summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Marçalo <raroma09@gmail.com>2022-10-22 21:33:30 +0100
committerRafael Marçalo <raroma09@gmail.com>2022-10-22 21:33:30 +0100
commitfab80a4d43b39839e67e762da19fdb7f9a53502f (patch)
treed9667938a15554e54f22eaae063c286e30974fd1
parent4f26ab9c157fe3c395f7e452120a97bc8cb8d8d8 (diff)
Started working on electron environment
-rw-r--r--.gitignore5
-rw-r--r--app.js3
-rw-r--r--launch.js34
-rw-r--r--package.json3
4 files changed, 42 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 69cc1db..1a94478 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
# NodeJS files
node_modules/
-package-lock.json \ No newline at end of file
+package-lock.json
+
+# Electron files
+out/ \ No newline at end of file
diff --git a/app.js b/app.js
index 115b0bf..d5e08a6 100644
--- a/app.js
+++ b/app.js
@@ -4,7 +4,8 @@
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
-const PORT = 7777;
+const PORT = module.exports.PORT = process.env.PORT || 3000;
+
// set the public folder to public acess and added a body parser
app.use(express.static('public'));
diff --git a/launch.js b/launch.js
new file mode 100644
index 0000000..d195f59
--- /dev/null
+++ b/launch.js
@@ -0,0 +1,34 @@
+const { app, BrowserWindow } = require('electron');
+const server = require('./app');
+
+function createWindow()
+{
+ const win = new BrowserWindow({
+ webPreferences: {
+ nodeIntegration: true,
+ }
+ });
+
+ // Window preferences on startup
+ win.maximize();
+ win.setMenu(null);
+ console.log(server.PORT);
+ win.loadURL('http://localhost:' + server.PORT);
+}
+
+app.whenReady().then(() => {
+ createWindow();
+
+ app.on('activate', () => {
+ if (BrowserWindow.getAllWindows().length === 0)
+ {
+ createWindow()
+ }
+ });
+});
+
+app.on('window-all-closed', () => {
+ if (process.platform !== 'darwin') {
+ app.quit()
+ }
+}); \ No newline at end of file
diff --git a/package.json b/package.json
index f2c7c36..ccdf53f 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
"description": "Piratebay indexing tool",
"main": "app.js",
"scripts": {
- "start": "node app.js",
+ "start": "electron launch.js",
"dev": "nodemon app.js"
},
"keywords": [
@@ -22,6 +22,7 @@
"express": "^4.18.2"
},
"devDependencies": {
+ "electron": "^21.2.0",
"nodemon": "^2.0.20"
}
}