@simitgroup/simpleapp-generator 1.0.9 → 1.0.15
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/README.md +148 -1
- package/dist/createproject.js +39 -18
- package/dist/createproject.js.map +1 -1
- package/dist/generate.js +47 -20
- package/dist/generate.js.map +1 -1
- package/dist/index.js +36 -25
- package/dist/index.js.map +1 -1
- package/dist/processors/jsonschemabuilder.js +38 -8
- package/dist/processors/jsonschemabuilder.js.map +1 -1
- package/dist/storage.js +5 -0
- package/dist/storage.js.map +1 -0
- package/package.json +10 -5
- package/src/createproject.ts +40 -14
- package/src/generate.ts +60 -28
- package/src/index.ts +31 -20
- package/src/processors/jsonschemabuilder.ts +48 -14
- package/src/storage.ts +3 -0
- package/src/type.ts +23 -1
- package/templates/SimpleAppClient.eta +10 -5
- package/templates/SimpleAppService.eta +65 -17
- package/templates/basic/model.eta +1 -1
- package/templates/basic/pageindex.vue.eta +50 -0
- package/templates/basic/pageindexwithid.vue.eta +1 -0
- package/templates/basic/{apiclient.eta → simpleappclient.eta} +6 -3
- package/templates/nuxt/app.vue.eta +8 -0
- package/templates/nuxt/components.crudsimple.vue.eta +95 -0
- package/templates/nuxt/components.debugdocdata.vue.eta +20 -0
- package/templates/nuxt/components.eventmonitor.vue.eta +79 -0
- package/templates/nuxt/components.menus.vue.eta +18 -0
- package/templates/nuxt/composables.getautocomplete.ts.eta +24 -0
- package/templates/nuxt/composables.getmenus.ts.eta +9 -0
- package/templates/nuxt/env.eta +3 -0
- package/templates/nuxt/layouts.default.vue.eta +10 -0
- package/templates/{nuxt.config.eta → nuxt/nuxt.config.ts.eta} +6 -3
- package/templates/nuxt/pages.index.vue.eta +3 -0
- package/templates/{nuxt.plugins.eta → nuxt/plugins.simpleapp.ts.eta} +11 -4
- package/templates/nuxt/server.api.ts.eta +131 -0
- package/templates/nuxt/tailwind.config.ts.eta +9 -0
- package/templates/nuxt/tailwind.css.eta +28 -0
- package/templates/nuxt.env.eta +0 -2
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
// import { getServerSession } from '#auth'
|
|
3
|
+
// import type { Session } from 'next-auth';
|
|
4
|
+
|
|
5
|
+
export default defineEventHandler(async (event) => {
|
|
6
|
+
// let session: Session | null = null
|
|
7
|
+
// try {
|
|
8
|
+
// session = await getServerSession(event)
|
|
9
|
+
// } catch (error) {
|
|
10
|
+
// return sendRedirect(event, '/login', 401)
|
|
11
|
+
// }
|
|
12
|
+
|
|
13
|
+
return new Promise<any>(async (resolve, reject) => {
|
|
14
|
+
// if(!session || !session.accessToken) {
|
|
15
|
+
// reject({ statusMessage: 'Unauthorized', statusCode: 401 });
|
|
16
|
+
// throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
|
|
17
|
+
// }
|
|
18
|
+
// console.log("------hihi------")
|
|
19
|
+
const seperateSymbol = '.';
|
|
20
|
+
// const seperateSymbol = '&';
|
|
21
|
+
const key = event.context.params?.key ?? ''
|
|
22
|
+
const platform = event.context.params?.platform ?? ''
|
|
23
|
+
const otherLink = event.context.params?._ ?? ''
|
|
24
|
+
|
|
25
|
+
// console.error("event.context???",event.context)
|
|
26
|
+
// const accessToken = session?.accessToken;
|
|
27
|
+
|
|
28
|
+
// const allowPlatform = ['report-api', 'cloudapi'];
|
|
29
|
+
// if(!key || !platform || !allowPlatform.includes(platform) || !accessToken) {
|
|
30
|
+
// reject({ statusMessage: 'Unauthorized', statusCode: 401 });
|
|
31
|
+
// // throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
|
|
32
|
+
// }
|
|
33
|
+
|
|
34
|
+
// let tenantKey = '', organizationKey = '';
|
|
35
|
+
// let xOrg = '';
|
|
36
|
+
|
|
37
|
+
// if(key !== 'system') {
|
|
38
|
+
// [tenantKey, organizationKey] = key.split(seperateSymbol);
|
|
39
|
+
// xOrg = `${tenantKey}/${organizationKey}/`;
|
|
40
|
+
// }
|
|
41
|
+
|
|
42
|
+
// if(key === 'system' && platform == 'cloudapi') {
|
|
43
|
+
// // xOrg = 'MC0wLTA'
|
|
44
|
+
// }
|
|
45
|
+
|
|
46
|
+
let forwardData: any = {};
|
|
47
|
+
|
|
48
|
+
const req = event.node.req;
|
|
49
|
+
|
|
50
|
+
if(req.method == 'POST' || req.method == 'PUT') {
|
|
51
|
+
|
|
52
|
+
forwardData = await readBody(event);
|
|
53
|
+
} else {
|
|
54
|
+
forwardData = getQuery(event);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// if(typeof forwardData === "object" && "_branch" in forwardData) {
|
|
58
|
+
// xOrg = xOrg + forwardData._branch;
|
|
59
|
+
// delete forwardData._branch;
|
|
60
|
+
// }
|
|
61
|
+
|
|
62
|
+
const frontEndRes = event.node.res;
|
|
63
|
+
const url = process.env.SIMPLEAPP_BACKEND_URL +platform + '/' + otherLink;
|
|
64
|
+
// console.warn('backend server-----',req.method,url,forwardData)
|
|
65
|
+
const axiosConfig: any = {
|
|
66
|
+
method: req.method,
|
|
67
|
+
url: url,
|
|
68
|
+
headers: {
|
|
69
|
+
// Authorization: `Bearer ${accessToken}`,
|
|
70
|
+
// 'X-Org': `${xOrg}`,
|
|
71
|
+
},
|
|
72
|
+
data: forwardData,
|
|
73
|
+
params: forwardData,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// if(key === 'system') {
|
|
77
|
+
// axiosConfig.headers["X-Global"] = true;
|
|
78
|
+
// delete axiosConfig.headers["X-Org"];
|
|
79
|
+
// }
|
|
80
|
+
|
|
81
|
+
// if(otherLink.includes('avatar')) {
|
|
82
|
+
// axiosConfig.responseType = 'arraybuffer';
|
|
83
|
+
// // axiosConfig.headers['Acceptable'] = 'text/html,image/avif,image/webp,image/apng';
|
|
84
|
+
// }
|
|
85
|
+
|
|
86
|
+
axios(axiosConfig).then((res) => {
|
|
87
|
+
if (res.headers['content-type'] === 'image/png') {
|
|
88
|
+
// Set the response headers for the image
|
|
89
|
+
frontEndRes.setHeader('Content-Type', 'image/png');
|
|
90
|
+
frontEndRes.setHeader('Content-Disposition', 'inline');
|
|
91
|
+
|
|
92
|
+
// Send the image data as the response body
|
|
93
|
+
frontEndRes.end(Buffer.from(res.data, 'binary'));
|
|
94
|
+
} else {
|
|
95
|
+
// For non-image responses, set the Content-Type header and send the response body
|
|
96
|
+
// setHeader(event, 'Content-type', <string>res.headers['Content-Type']);
|
|
97
|
+
|
|
98
|
+
frontEndRes.statusCode = res.status;
|
|
99
|
+
if(res.statusText) {
|
|
100
|
+
frontEndRes.statusMessage = res.statusText;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
resolve(res.data);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
}).catch((error) => {
|
|
107
|
+
// console.log("==============================================================")
|
|
108
|
+
// console.log('@@@@@@@@@@@@@ API error', error)
|
|
109
|
+
// console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
|
|
110
|
+
// console.log('######### response', error.response)
|
|
111
|
+
// console.log('#####################################')
|
|
112
|
+
// console.log(axiosConfig);
|
|
113
|
+
// console.log('#####################################')
|
|
114
|
+
|
|
115
|
+
if (error.response?.status && error.response.status == '401') {
|
|
116
|
+
return reject({ statusMessage: 'Unauthorized', statusCode: 401 });
|
|
117
|
+
// throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// reject(error.data)
|
|
121
|
+
reject({ statusMessage: error.response.statusText, statusCode: error.response.status });
|
|
122
|
+
// resolve({ status: 'ok' })
|
|
123
|
+
// throw createError({ statusMessage: 'Bad Requests', statusCode: 404 })
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
// resolve({
|
|
127
|
+
// status: 'ok'
|
|
128
|
+
// })
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@tailwind base;
|
|
2
|
+
@tailwind components;
|
|
3
|
+
@tailwind utilities;
|
|
4
|
+
|
|
5
|
+
button {
|
|
6
|
+
@apply p-2 border-2
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.input-error{
|
|
10
|
+
@apply text-red-500
|
|
11
|
+
}
|
|
12
|
+
.simpleapp-tool-bar button{
|
|
13
|
+
margin-right: 1rem;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.bg-primary{
|
|
17
|
+
@apply bg-green-600 text-white
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
.bg-default{
|
|
21
|
+
@apply bg-white
|
|
22
|
+
}
|
|
23
|
+
.bg-danger{
|
|
24
|
+
@apply bg-red-500 text-white
|
|
25
|
+
}
|
|
26
|
+
.bg-warning{
|
|
27
|
+
@apply bg-orange-600 text-white
|
|
28
|
+
}
|
package/templates/nuxt.env.eta
DELETED