create-prisma-php-app 1.20.520 → 1.20.521
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.htaccess +1 -1
- package/dist/bootstrap.php +3 -1
- package/dist/index.js +4 -2
- package/dist/prisma-client-php/index.enc +1 -1
- package/dist/prisma-client-php/index.js +6 -2
- package/dist/src/Lib/Auth/Auth.php +9 -0
- package/dist/src/Lib/StateManager.php +9 -0
- package/dist/src/app/swagger-docs/apis/pphp-swagger.json +25 -25
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as fs from"fs";import{exec}from"child_process";import path from"path";import{fileURLToPath}from"url";import CryptoJS from"crypto-js";const __filename=fileURLToPath(import.meta.url),__dirname=path.dirname(__filename),getSecretKey=()=>{const r=fs.readFileSync(`${__dirname}/key.enc`,"utf8");if(r.length<400)throw new Error("File content is less than 400 characters.");return r.substring(247,289)},decryptData=(r,t)=>CryptoJS.AES.decrypt(r,t).toString(CryptoJS.enc.Utf8);
|
|
1
|
+
import*as fs from"fs";import{exec}from"child_process";import path from"path";import{fileURLToPath}from"url";import CryptoJS from"crypto-js";import chalk from"chalk";const __filename=fileURLToPath(import.meta.url),__dirname=path.dirname(__filename),getSecretKey=()=>{const r=fs.readFileSync(`${__dirname}/key.enc`,"utf8");if(r.length<400)throw new Error("File content is less than 400 characters.");return r.substring(247,289)},decryptData=(r,t)=>CryptoJS.AES.decrypt(r,t).toString(CryptoJS.enc.Utf8);
|
|
2
2
|
const executePHP = (command) => {
|
|
3
3
|
exec(command, (error, stdout, stderr) => {
|
|
4
4
|
if (error) {
|
|
@@ -9,7 +9,11 @@ const executePHP = (command) => {
|
|
|
9
9
|
console.error(`Standard error: ${stderr}`);
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
if (stdout.includes("Result: Prisma schema is valid.")) {
|
|
13
|
+
console.error(chalk.blue(stdout));
|
|
14
|
+
} else {
|
|
15
|
+
console.log(`Standard output...\n${stdout}`);
|
|
16
|
+
}
|
|
13
17
|
});
|
|
14
18
|
};
|
|
15
19
|
const main=async()=>{try{const e=process.cwd(),n=path.join(e,"prisma-php.json"),a=fs.readFileSync(n,{encoding:"utf8"}),c=JSON.parse(a),t=c.phpGenerateClassPath,i=`${__dirname}/index.php`,p=`${__dirname}/index.enc`,s=getSecretKey(),r=fs.readFileSync(p,{encoding:"utf8"}),d=decryptData(r,s);fs.writeFileSync(`${__dirname}/index.php`,d);const h=`${c.phpRootPathExe} ${i} ${t}`;executePHP(h)}catch(e){}};main().catch((e=>{}));
|
|
@@ -22,11 +22,20 @@ class Auth
|
|
|
22
22
|
private $secretKey;
|
|
23
23
|
private $defaultTokenValidity = '1h'; // Default to 1 hour
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Private constructor to prevent direct instantiation.
|
|
27
|
+
* Use Auth::getInstance() to get the singleton instance.
|
|
28
|
+
*/
|
|
25
29
|
private function __construct()
|
|
26
30
|
{
|
|
27
31
|
$this->secretKey = $_ENV['AUTH_SECRET'];
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Returns the singleton instance of the Auth class.
|
|
36
|
+
*
|
|
37
|
+
* @return Auth The singleton instance.
|
|
38
|
+
*/
|
|
30
39
|
public static function getInstance(): Auth
|
|
31
40
|
{
|
|
32
41
|
if (self::$instance === null) {
|
|
@@ -12,6 +12,10 @@ class StateManager
|
|
|
12
12
|
private array $state = [];
|
|
13
13
|
private array $listeners = [];
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Constructs a new instance of the StateManager class.
|
|
17
|
+
* Use StateManager::getInstance() to get the singleton instance.
|
|
18
|
+
*/
|
|
15
19
|
private function __construct()
|
|
16
20
|
{
|
|
17
21
|
global $isWire;
|
|
@@ -23,6 +27,11 @@ class StateManager
|
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Gets the singleton instance of the StateManager class.
|
|
32
|
+
*
|
|
33
|
+
* @return StateManager The singleton instance of the StateManager class.
|
|
34
|
+
*/
|
|
26
35
|
public static function getInstance(): StateManager
|
|
27
36
|
{
|
|
28
37
|
if (self::$instance === null) {
|
|
@@ -7,21 +7,33 @@
|
|
|
7
7
|
},
|
|
8
8
|
"servers": [
|
|
9
9
|
{
|
|
10
|
-
"url": "http://localhost:
|
|
11
|
-
"description": "Server"
|
|
10
|
+
"url": "http://localhost:3004",
|
|
11
|
+
"description": "Development Server"
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
|
-
"url": "your-domain",
|
|
15
|
-
"description": "Server"
|
|
14
|
+
"url": "your-production-domain",
|
|
15
|
+
"description": "Production Server"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"components": {
|
|
19
|
+
"securitySchemes": {
|
|
20
|
+
"bearerAuth": {
|
|
21
|
+
"type": "http",
|
|
22
|
+
"scheme": "bearer",
|
|
23
|
+
"bearerFormat": "JWT"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"security": [
|
|
28
|
+
{
|
|
29
|
+
"bearerAuth": []
|
|
16
30
|
}
|
|
17
31
|
],
|
|
18
32
|
"paths": {
|
|
19
33
|
"/users": {
|
|
20
34
|
"get": {
|
|
21
35
|
"summary": "Retrieve a list of users",
|
|
22
|
-
"tags": [
|
|
23
|
-
"Users"
|
|
24
|
-
],
|
|
36
|
+
"tags": ["Users"],
|
|
25
37
|
"responses": {
|
|
26
38
|
"200": {
|
|
27
39
|
"description": "A list of users",
|
|
@@ -54,19 +66,14 @@
|
|
|
54
66
|
},
|
|
55
67
|
"post": {
|
|
56
68
|
"summary": "Create a new user",
|
|
57
|
-
"tags": [
|
|
58
|
-
"Users"
|
|
59
|
-
],
|
|
69
|
+
"tags": ["Users"],
|
|
60
70
|
"requestBody": {
|
|
61
71
|
"required": true,
|
|
62
72
|
"content": {
|
|
63
73
|
"application/json": {
|
|
64
74
|
"schema": {
|
|
65
75
|
"type": "object",
|
|
66
|
-
"required": [
|
|
67
|
-
"name",
|
|
68
|
-
"email"
|
|
69
|
-
],
|
|
76
|
+
"required": ["name", "email"],
|
|
70
77
|
"properties": {
|
|
71
78
|
"name": {
|
|
72
79
|
"type": "string",
|
|
@@ -112,9 +119,7 @@
|
|
|
112
119
|
"/users/{id}": {
|
|
113
120
|
"get": {
|
|
114
121
|
"summary": "Retrieve a single user by ID",
|
|
115
|
-
"tags": [
|
|
116
|
-
"Users"
|
|
117
|
-
],
|
|
122
|
+
"tags": ["Users"],
|
|
118
123
|
"parameters": [
|
|
119
124
|
{
|
|
120
125
|
"in": "path",
|
|
@@ -158,9 +163,7 @@
|
|
|
158
163
|
},
|
|
159
164
|
"put": {
|
|
160
165
|
"summary": "Update a user by ID",
|
|
161
|
-
"tags": [
|
|
162
|
-
"Users"
|
|
163
|
-
],
|
|
166
|
+
"tags": ["Users"],
|
|
164
167
|
"parameters": [
|
|
165
168
|
{
|
|
166
169
|
"in": "path",
|
|
@@ -224,9 +227,7 @@
|
|
|
224
227
|
},
|
|
225
228
|
"delete": {
|
|
226
229
|
"summary": "Delete a user by ID",
|
|
227
|
-
"tags": [
|
|
228
|
-
"Users"
|
|
229
|
-
],
|
|
230
|
+
"tags": ["Users"],
|
|
230
231
|
"parameters": [
|
|
231
232
|
{
|
|
232
233
|
"in": "path",
|
|
@@ -249,11 +250,10 @@
|
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
252
|
},
|
|
252
|
-
"components": {},
|
|
253
253
|
"tags": [
|
|
254
254
|
{
|
|
255
255
|
"name": "Users",
|
|
256
256
|
"description": "User management API"
|
|
257
257
|
}
|
|
258
258
|
]
|
|
259
|
-
}
|
|
259
|
+
}
|