zet-lib 1.0.21 → 1.0.22

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/lib/zPage.js CHANGED
@@ -54,7 +54,7 @@ const csrfProtection = csrf({cookie: true});
54
54
  const fs = require('fs-extra');
55
55
  const qs = require('qs');
56
56
  const axios = require('axios');
57
- const {zRoute, zRole, connection, Util, io, zCache, myCache, debug, moduleLib, zFunction, zFn, Mail } = require('zet-lib');
57
+ const { connection, Util, io, zCache, myCache, zDebug, zDataTable, moduleLib, zFunction, zFn, zMail, zRoute, zRole} = require('zet-lib');
58
58
 
59
59
  `;
60
60
  };
@@ -159,6 +159,7 @@ zpage.buildLayout = async (obj) => {
159
159
  minifyCSS:true,
160
160
  collapseWhitespace: true
161
161
  });
162
+ console.log(dirRoot + "/views/layouts/" + name + ".ejs");
162
163
  fs.writeFileSync(dirRoot + "/views/layouts/" + name + ".ejs", html, 'utf-8');
163
164
  if (process.env.NODE_ENV === "production") {
164
165
  setTimeout(function () {
package/lib/zRoute.js CHANGED
@@ -51,6 +51,34 @@ zRoute.ROUTES = () => {
51
51
  return arr;
52
52
  };
53
53
 
54
+ //translate render and optimize so javascript can direct inject
55
+ zRoute.renderHTML = (datas)=> {
56
+ let renderBody=renderEnd=bodyHTML=endHTML='';
57
+ if(datas.hasOwnProperty('renderBody')) {
58
+ renderBody = datas.renderBody.replaceAll('/','_').replaceAll('.','_');
59
+ if(myCache.has(renderBody)){
60
+ bodyHTML = myCache.get(renderBody);
61
+ } else {
62
+ bodyHTML = Util.readFile(`${dirRoot}/views/${datas.renderBody}`);
63
+ myCache.set(renderBody, bodyHTML);
64
+ }
65
+ delete datas.renderBody;
66
+ }
67
+ if(datas.hasOwnProperty('renderEnd')) {
68
+ renderEnd = datas.renderEnd.replaceAll('/','_').replaceAll('.','_');
69
+ if(myCache.has(renderEnd)){
70
+ endHTML = myCache.get(renderEnd);
71
+ } else {
72
+ endHTML = Util.readFile(`${dirRoot}/views/${datas.renderEnd}`);
73
+ myCache.set(renderEnd, endHTML);
74
+ }
75
+ delete datas.renderEnd;
76
+ }
77
+
78
+ datas.bodyHTML = ejs.render(bodyHTML,datas);
79
+ datas.endHTML = ejs.render(endHTML,datas);
80
+ return datas;
81
+ }
54
82
  /*
55
83
  Auto updated_at,created_at,company_id,created_by,updated_by
56
84
  */
@@ -3312,7 +3340,7 @@ zRoute.makeFunctionsSystem = () => {
3312
3340
  content += Util.newLine;
3313
3341
  }
3314
3342
  }
3315
- let templateSystem = `const {zRole, zCache, myCache, Util, io, moment, Mail} = require('zet-lib');
3343
+ let templateSystem = `const { connection, Util, io, zCache, myCache, zDebug, zDataTable, moduleLib, zFunction, zFn, zMail, zRoute, zRole} = require('zet-lib');
3316
3344
  module.exports = (req, res, next) => {`;
3317
3345
  let fileSystem = `${dirRoot}/components/zFunctionsSystem.js`;
3318
3346
  templateSystem += content;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"