zet-lib 1.0.20 → 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
@@ -19,8 +19,6 @@ const moment = require('moment');
19
19
  const debug = require("./debug");
20
20
  const moduleLib = require("./moduleLib");
21
21
  const cForm = require("./Form");
22
- const config = require('dotenv').config();
23
- //const dirRoot = process.env.dirRoot;
24
22
 
25
23
  const zRoute = {};
26
24
 
@@ -53,6 +51,34 @@ zRoute.ROUTES = () => {
53
51
  return arr;
54
52
  };
55
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
+ }
56
82
  /*
57
83
  Auto updated_at,created_at,company_id,created_by,updated_by
58
84
  */
@@ -3314,7 +3340,7 @@ zRoute.makeFunctionsSystem = () => {
3314
3340
  content += Util.newLine;
3315
3341
  }
3316
3342
  }
3317
- 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');
3318
3344
  module.exports = (req, res, next) => {`;
3319
3345
  let fileSystem = `${dirRoot}/components/zFunctionsSystem.js`;
3320
3346
  templateSystem += content;
package/lib/zapp.js CHANGED
@@ -1,4 +1,3 @@
1
- const config = require('dotenv').config();
2
1
  module.exports = (req,res,next) => {
3
2
  res.locals.renderHead = "";
4
3
  res.locals.renderBody = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"