From 6f23e7057877dea8d3c50314dad88cf04943ff6d Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Fri, 23 Feb 2024 22:19:32 +0100 Subject: [PATCH 1/3] prepare backend and mysql for database authentication closes #4 --- src/templates/public/api.php | 5 ++++- src/templates/schema.sql | 15 +++++++++------ src/templates/testdata.sql | 3 +++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/templates/public/api.php b/src/templates/public/api.php index 0a631d8..4d7c29f 100644 --- a/src/templates/public/api.php +++ b/src/templates/public/api.php @@ -24,7 +24,10 @@ 'address' => MYSQL_HOST, 'database' => MYSQL_DATABASE, 'username' => MYSQL_USERNAME, - 'password' => MYSQL_PASSWORD + 'password' => MYSQL_PASSWORD, + + // Database Authentication + 'middlewares' => 'dbAuth' ]); diff --git a/src/templates/schema.sql b/src/templates/schema.sql index f4846cf..5ffb15f 100644 --- a/src/templates/schema.sql +++ b/src/templates/schema.sql @@ -1,8 +1,11 @@ -CREATE TABLE IF NOT EXISTS `tasks` ( - `id` int(4) NOT NULL AUTO_INCREMENT, - `title` varchar(255) NOT NULL DEFAULT "", - PRIMARY KEY(`id`) +CREATE TABLE IF NOT EXISTS `users` ( + `id` integer(4) NOT NULL PRIMARY KEY AUTO_INCREMENT, + `username` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -ALTER TABLE `tasks` -ADD COLUMN `done` int(1) NOT NULL DEFAULT 0; \ No newline at end of file +CREATE TABLE IF NOT EXISTS `tasks` ( + `id` integer(4) NOT NULL PRIMARY KEY AUTO_INCREMENT, + `title` varchar(255) NOT NULL, + `done` integer(1) NOT NULL DEFAULT 0 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; \ No newline at end of file diff --git a/src/templates/testdata.sql b/src/templates/testdata.sql index 4d13f7f..7732132 100644 --- a/src/templates/testdata.sql +++ b/src/templates/testdata.sql @@ -1,2 +1,5 @@ +INSERT IGNORE INTO `users` (`id`, `username`, `password`) +VALUES (1, "root", "cm9vdA=="); + INSERT IGNORE INTO `tasks` (`id`, `title`, `done`) VALUES (1, "First Task", 1), (2, "Second Task", 0), (3, "Third Task", 1); \ No newline at end of file From cc9de1bff1f8bf86052c1b90bd0c5be3f6d25379 Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Fri, 23 Feb 2024 22:19:39 +0100 Subject: [PATCH 2/3] use demo folder --- .gitignore | 2 +- README.md | 8 +++++--- package.json | 2 +- src/index.js | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) mode change 100644 => 100755 src/index.js diff --git a/.gitignore b/.gitignore index 201ce0c..808ffe5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ node_modules/ -temp/ +demo/ .DS_Store \ No newline at end of file diff --git a/README.md b/README.md index 9bf4130..671f002 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ Report bugs in the [issues list](https://github.com/scriptPilot/add-php-backend/ ## Maintainer -1. Commit changes with an issue (closure) reference -2. Run `npm version patch | minor | major` and push changes -3. Let the workflow manage the release to GitHub and NPM +1. Apply changes +2. Run `npm run backend` to build the `demo` folder +3. Commit changes with an issue (closure) reference +4. Run `npm version patch | minor | major` and push changes +5. Let the workflow manage the release to GitHub and NPM diff --git a/package.json b/package.json index ad6d02e..d4800fe 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "type": "module", "scripts": { "test": "", - "backend": "rm -rf temp && node . && cd temp && npm run backend", + "backend": "rm -rf demo && node . && cd demo && npm run backend", "preversion": "npm install && npm test" }, "repository": { diff --git a/src/index.js b/src/index.js old mode 100644 new mode 100755 index a761a8d..b0fe02a --- a/src/index.js +++ b/src/index.js @@ -10,7 +10,7 @@ import fs from 'fs-extra' const scriptFolder = path.dirname(url.fileURLToPath(import.meta.url)) const processFolder = process.cwd() const isDevMode = processFolder === path.resolve(scriptFolder, '..') -const appFolder = isDevMode ? path.resolve(scriptFolder, '../temp') : processFolder +const appFolder = isDevMode ? path.resolve(scriptFolder, '../demo') : processFolder const templateFolder = path.resolve(scriptFolder, 'templates') // Define files From c382419aaabad5272f2fdc2eed674ff756c5c070 Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Fri, 23 Feb 2024 22:19:47 +0100 Subject: [PATCH 3/3] 1.5.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index d43cae6..3a316c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "add-php-backend", - "version": "1.4.7", + "version": "1.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "add-php-backend", - "version": "1.4.7", + "version": "1.5.0", "license": "MIT", "dependencies": { "fs-extra": "^11.2.0", diff --git a/package.json b/package.json index d4800fe..0d53bf3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "add-php-backend", - "version": "1.4.7", + "version": "1.5.0", "description": "", "main": "src/index.js", "bin": "src/index.js",