create-prisma-php-app 1.22.3 → 1.22.5

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.
@@ -1,89 +0,0 @@
1
- import swaggerJsdoc from "swagger-jsdoc";
2
- import { writeFileSync, readFileSync, existsSync } from "fs";
3
- import { fileURLToPath } from "url";
4
- import { join, dirname } from "path";
5
- import chalk from "chalk";
6
-
7
- // Define __dirname equivalent in ES modules
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = dirname(__filename);
10
-
11
- // Define the output path for the swagger.json file
12
- const outputPath = join(
13
- __dirname,
14
- "../src/app/swagger-docs/apis/pphp-swagger.json"
15
- );
16
-
17
- const bsConnectionInfo = join(__dirname, "bs-output.json");
18
-
19
- // Check if the bs-output.json file exists
20
- const defaultConnectionInfo = {
21
- local: "http://localhost:3000",
22
- external: "http://192.168.1.5:3000",
23
- ui: "http://localhost:3001",
24
- uiExternal: "http://192.168.1.5:3001",
25
- };
26
-
27
- let jsonData = defaultConnectionInfo;
28
-
29
- if (existsSync(bsConnectionInfo)) {
30
- try {
31
- const data = readFileSync(bsConnectionInfo, "utf8");
32
- jsonData = JSON.parse(data);
33
- } catch (error) {
34
- console.error("Error parsing bs-output.json:", error);
35
- }
36
- } else {
37
- console.warn("bs-output.json not found, using default connection info.");
38
- }
39
-
40
- const options = {
41
- definition: {
42
- openapi: "3.0.0",
43
- info: {
44
- title: "Prisma PHP API Documentation",
45
- version: "1.0.0",
46
- description: "API documentation for the Prisma PHP project",
47
- },
48
- servers: [
49
- {
50
- url: jsonData.local, // For Development
51
- description: "Development Server",
52
- },
53
- {
54
- url: "your-production-domain", // For Production
55
- description: "Production Server",
56
- },
57
- ],
58
- components: {
59
- securitySchemes: {
60
- bearerAuth: {
61
- type: "http",
62
- scheme: "bearer",
63
- bearerFormat: "JWT",
64
- },
65
- },
66
- },
67
- security: [
68
- {
69
- bearerAuth: [],
70
- },
71
- ],
72
- },
73
- apis: [join(__dirname, "../src/app/swagger-docs/apis/**/*.js")], // Path to your API routes
74
- };
75
-
76
- // Generate the Swagger specification
77
- const swaggerSpec = JSON.stringify(swaggerJsdoc(options), null, 2);
78
-
79
- // Always generate the swagger.json file
80
- try {
81
- writeFileSync(outputPath, swaggerSpec, "utf-8");
82
- console.log(
83
- `Swagger JSON has been generated and saved to ${chalk.blue(
84
- "src/app/swagger-docs/pphp-swagger.json"
85
- )}`
86
- );
87
- } catch (error) {
88
- console.error("Error saving Swagger JSON:", error);
89
- }