jcc-express-mvc 1.4.2 → 1.4.4

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 +1 @@
1
- {"version":3,"file":"AuthMiddleware.d.ts","sourceRoot":"","sources":["../../../framework/lib/Auth/AuthMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhE,cAAM,cAAc;IACL,OAAO,CAClB,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,GAAG,CAAC;IAqCR,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,GAAG,GAAG;IAWpE,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;CAQ9D;AAED,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
1
+ {"version":3,"file":"AuthMiddleware.d.ts","sourceRoot":"","sources":["../../../framework/lib/Auth/AuthMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhE,cAAM,cAAc;IACL,OAAO,CAClB,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,GAAG,CAAC;IAqCR,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,GAAG,GAAG;IAYpE,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;CAO9D;AAED,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
@@ -41,6 +41,7 @@ class AuthMiddleware {
41
41
  }
42
42
  auth(request, response, next) {
43
43
  let url = "";
44
+ response.locals.Auth = request.user || {};
44
45
  if (request.url) {
45
46
  url = request.url;
46
47
  request.session["appRedirect"] = url;
@@ -50,7 +51,6 @@ class AuthMiddleware {
50
51
  : response.redirect(url ? `/login?redirect=${url}` : "/login");
51
52
  }
52
53
  guest(req, res, next) {
53
- res.locals.Auth = req.user || {};
54
54
  if (req.isAuthenticated()) {
55
55
  return res.redirectBack();
56
56
  }
@@ -49,5 +49,6 @@ export declare class EngineHelpers extends TemplateRegex {
49
49
  protected getAssetPath(resolvePath: string, beforeMatch: string, afterMatch: string): string;
50
50
  protected addCSSLinkTag(link: string): string;
51
51
  protected getResource(resources: Array<string>, select?: number): string;
52
+ protected injectReactRefefresh(): string;
52
53
  }
53
54
  //# sourceMappingURL=engineHelper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engineHelper.d.ts","sourceRoot":"","sources":["../../../framework/lib/Templating-engine/engineHelper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI9C,qBAAa,aAAc,SAAQ,aAAa;IAE9C,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC;;IAK3B;;;;;OAKG;IACH,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,WAAW;IAM3D;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;;;;OAKG;IACH,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM;IA2BhE;;;;;OAKG;IACH,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM;IAKxE;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAYxC;;;;OAIG;IACH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IAYxC;;;;OAIG;IACH,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAI3C,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG;IAgC1D,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM;IAWnC,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM;IAOpC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM;IAgClC,SAAS,CAAC,YAAY,CACpB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,MAAM;IA2BT,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM;IAIpC,SAAS,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,GAAE,MAAU;IAOlE,SAAS,CAAC,oBAAoB;CAS/B"}
@@ -9,6 +9,7 @@ const AppError_1 = require("../Error/AppError");
9
9
  const expressions_1 = require("./expressions");
10
10
  const app_root_path_1 = __importDefault(require("app-root-path"));
11
11
  const fs_1 = __importDefault(require("fs"));
12
+ const colors_1 = __importDefault(require("colors"));
12
13
  class EngineHelpers extends expressions_1.TemplateRegex {
13
14
  constructor() {
14
15
  super();
@@ -93,7 +94,7 @@ class EngineHelpers extends expressions_1.TemplateRegex {
93
94
  .toString();
94
95
  }
95
96
  catch (error) {
96
- console.log(path + " not found");
97
+ console.log(colors_1.default.red(path + " not found"));
97
98
  }
98
99
  return "";
99
100
  }
@@ -181,14 +182,14 @@ class EngineHelpers extends expressions_1.TemplateRegex {
181
182
 
182
183
  */
183
184
  getAssetPath(resolvePath, beforeMatch, afterMatch) {
184
- console.log({ vite: this.viteHost });
185
185
  if (Config_1.config.get("APP_ENV") === "local") {
186
186
  const src = `${this.viteHost}/${resolvePath}`;
187
187
  return `${beforeMatch}${this.addScriptTag(src)}${afterMatch}`;
188
188
  }
189
189
  const manifestContent = this.getPublicFile("build/manifest.json");
190
190
  if (!manifestContent) {
191
- throw new AppError_1.AppError("Run npm run vite in your terminal");
191
+ console.log(colors_1.default.yellow("Run npm run vite in your terminal"));
192
+ return "";
192
193
  }
193
194
  const manifest = JSON.parse(manifestContent);
194
195
  const assetData = manifest[resolvePath];
@@ -209,5 +210,14 @@ class EngineHelpers extends expressions_1.TemplateRegex {
209
210
  const resource = resources[resources.length > 1 ? select : 0].trim();
210
211
  return this.removeQuotes(resource.startsWith("/") ? resource.slice(1) : resource);
211
212
  }
213
+ injectReactRefefresh() {
214
+ return ` <script type="module">
215
+ import RefreshRuntime from '${this.viteHost}/@react-refresh';
216
+ RefreshRuntime.injectIntoGlobalHook(window);
217
+ window.$RefreshReg$ = () => {};
218
+ window.$RefreshSig$ = () => (type) => type;
219
+ window.__vite_plugin_react_preamble_installed__ = true;
220
+ </script>`;
221
+ }
212
222
  }
213
223
  exports.EngineHelpers = EngineHelpers;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../framework/lib/Templating-engine/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,cAAM,gBAAiB,SAAQ,aAAa;IAC1C,OAAO,CAAC,MAAM,CAAM;IAEpB;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAYtB;;;;;;OAMG;IACH,OAAO,CAAC,UAAU;IAuBlB;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAevB;;;;;;OAMG;IACH,OAAO,CAAC,OAAO;IAYf;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgB/C;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IAYhB;;;;;;OAMG;IACH,OAAO,CAAC,IAAI;IAmBZ;;;;;;OAMG;IACH,OAAO,CAAC,KAAK;IASb,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,IAAI;IAgB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C,MAAM,CAAC;IAQpD,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG;IAazD,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,MAAM;CAG3C;AAGD,QAAA,MAAM,OAAO,SANG,MAAM,UAAU,GAAG,KAAG,MAMK,CAAC;AAC5C,QAAA,MAAM,aAAa,kBAAS,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC"}
@@ -5,10 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.compile = exports.jsBladeEngine = void 0;
7
7
  const Config_1 = require("../Config/Config");
8
- const AppError_1 = require("../Error/AppError");
9
- const error_1 = require("../Error/Constants/error");
8
+ // import { AppError } from "../Error/AppError";
9
+ // import { DEFAULT_ENGINE_ERROR } from "../Error/Constants/error";
10
10
  const engineHelper_1 = require("./engineHelper");
11
11
  const fs_1 = __importDefault(require("fs"));
12
+ const colors_1 = __importDefault(require("colors"));
12
13
  class TemplatingEngine extends engineHelper_1.EngineHelpers {
13
14
  constructor() {
14
15
  super(...arguments);
@@ -184,6 +185,7 @@ class TemplatingEngine extends engineHelper_1.EngineHelpers {
184
185
  const resourcePath = this.removeQuotes(match?.groups.resource || "").split(",");
185
186
  if (Config_1.config.get("APP_ENV") === "local" && resourcePath.length > 1) {
186
187
  beforMatch += this.addCSSLinkTag(`${this.viteHost}/${this.getResource(resourcePath, 0)}`);
188
+ beforMatch += this.addScriptTag(this.viteHost + "/@vite/client");
187
189
  }
188
190
  const resources = this.getResource(resourcePath);
189
191
  return this.parser(this.getAssetPath(resources, beforMatch, afterMatch));
@@ -192,7 +194,7 @@ class TemplatingEngine extends engineHelper_1.EngineHelpers {
192
194
  const { beforMatch, afterMatch } = this.content(content, match);
193
195
  let viteClientRefresh = "";
194
196
  if (Config_1.config.get("APP_ENV") == "local") {
195
- viteClientRefresh = this.addScriptTag(this.viteHost + "/@vite/client");
197
+ // viteClientRefresh = this.injectReactRefefresh();
196
198
  }
197
199
  return this.parser(beforMatch + viteClientRefresh + afterMatch);
198
200
  }
@@ -253,8 +255,8 @@ class TemplatingEngine extends engineHelper_1.EngineHelpers {
253
255
  return callback(null, renderedContent);
254
256
  }
255
257
  catch (error) {
256
- console.log({ error });
257
- throw new AppError_1.AppError(error?.message, error_1.DEFAULT_ENGINE_ERROR);
258
+ return console.log(colors_1.default.red(error.message));
259
+ // throw new AppError(error?.message, DEFAULT_ENGINE_ERROR);
258
260
  }
259
261
  }
260
262
  Content(path, option) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jcc-express-mvc",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "express mvc structure",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",