@simitgroup/simpleapp-generator 1.6.4-b-alpha → 1.6.4-c-alpha

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simitgroup/simpleapp-generator",
3
- "version": "1.6.4b-alpha",
3
+ "version": "1.6.4c-alpha",
4
4
  "description": "frontend nuxtjs and backend nests code generator using jsonschema",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -18,6 +18,7 @@ const after = (actionName: string, data: <%= it.typename %>) => {
18
18
  break;
19
19
  case "create":
20
20
  emits("afterCreate", data);
21
+ refreshDocumentList('<%= it.name %>')
21
22
  break;
22
23
  case "update":
23
24
  break;
@@ -75,6 +75,34 @@ export default defineEventHandler(async (event:any) => {
75
75
 
76
76
  // Send the image data as the response body
77
77
  frontEndRes.end(Buffer.from(res.data, 'binary'));
78
+ }else if(documentLink.includes('images/')){
79
+ // console.log(documentLink," Resdata of base64 photo",res.data.length)
80
+ let imageData
81
+ frontEndRes.setHeader('Content-Type', 'image/png');
82
+
83
+ // console.log("load image for",documentLink)
84
+ if( res.data.length){
85
+ // console.log("obtain base64 from server length:",res.data.length)
86
+ imageData = base64ToBuffer(res.data);
87
+
88
+ }else{
89
+ // console.log("server no image, use default image")
90
+ const folder = 'public/images/'
91
+ let filename = ''
92
+ if(documentLink.includes('student')) filename='student.png';
93
+ else if(documentLink.includes('teacher')) filename='teacher.png';
94
+ else if(documentLink.includes('organization')) filename='organization.png';
95
+ else filename='unknown.png';
96
+ const fullpath = folder+filename;
97
+ // console.log("photo path",fullpath)
98
+ if(fs.existsSync(fullpath)){
99
+ imageData = fs.readFileSync(fullpath)
100
+ }else{
101
+ console.log(fullpath,'does not exists')
102
+ }
103
+ }
104
+ frontEndRes.end(Buffer.from(imageData, 'binary'));
105
+
78
106
  } else {
79
107
  // For non-image responses, set the Content-Type header and send the response body
80
108
  // setHeader(event, 'Content-type', <string>res.headers['Content-Type']);
@@ -113,4 +141,19 @@ export default defineEventHandler(async (event:any) => {
113
141
  // })
114
142
  })
115
143
 
116
- })
144
+ })
145
+
146
+
147
+
148
+ function base64ToBuffer(base64String:string) {
149
+ // Split the base64 string into parts
150
+ const parts = base64String.split(',');
151
+ const contentType = parts[0].split(':')[1];
152
+ const base64Data = parts[1];
153
+
154
+ // Decode the base64 data
155
+ const binaryString = atob(base64Data);
156
+ const buffer = new Buffer.from(binaryString, 'binary');
157
+
158
+ return buffer
159
+ }