jcc-express-mvc 1.6.4 → 1.6.5

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.
@@ -8,7 +8,12 @@ export declare class Middleware {
8
8
  constructor(app: Application);
9
9
  loadStaticFiles(): void;
10
10
  use(globalMiddleares: RequestHandler[]): void;
11
- private defaultTemplatingEngine;
11
+ /**
12
+ * Default templating engine for the application.
13
+ * It sets up the Blade templating engine with the express app.
14
+ */
15
+ private templatingEngine;
12
16
  passportMiddleware(): RequestHandler;
17
+ private corsOption;
13
18
  }
14
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAyB,EAEvB,cAAc,EACf,MAAM,SAAS,CAAC;AAUjB,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,GAAG,CAAc;gBAEb,GAAG,EAAE,WAAW;IAO5B,eAAe;IAMf,GAAG,CAAC,gBAAgB,EAAE,cAAc,EAAE;IAgBtC,OAAO,CAAC,uBAAuB;IASxB,kBAAkB,IAAI,cAAc;CAM5C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Middleware/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAyB,EAEvB,cAAc,EACf,MAAM,SAAS,CAAC;AAQjB,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,GAAG,CAAc;gBAEb,GAAG,EAAE,WAAW;IAO5B,eAAe;IAMf,GAAG,CAAC,gBAAgB,EAAE,cAAc,EAAE;IAiBtC;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAQjB,kBAAkB,IAAI,cAAc;IAO3C,OAAO,CAAC,UAAU;CAGnB"}
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Middleware = void 0;
7
7
  const passport_1 = __importDefault(require("passport"));
8
8
  const serve_favicon_1 = __importDefault(require("serve-favicon"));
9
+ const cors_1 = __importDefault(require("cors"));
9
10
  const Response_1 = require("../Response");
10
11
  const request_1 = require("../Request/request");
11
- const Templating_engine_1 = require("../Templating-engine");
12
12
  const config_1 = require("../Passport/config");
13
13
  class Middleware {
14
14
  //
@@ -20,7 +20,7 @@ class Middleware {
20
20
  this.expressApp.disable("x-powered-by");
21
21
  }
22
22
  loadStaticFiles() {
23
- this.defaultTemplatingEngine();
23
+ this.templatingEngine();
24
24
  this.expressApp.use(this.express.static(`${this.rootPath}/public`));
25
25
  this.expressApp.use(this.express.static(`${this.rootPath}/resources`));
26
26
  this.expressApp.use((0, serve_favicon_1.default)(`${this.rootPath}/public/favicon.ico`));
@@ -30,6 +30,7 @@ class Middleware {
30
30
  [
31
31
  this.express.json(),
32
32
  this.express.urlencoded({ extended: false }),
33
+ (0, cors_1.default)(this.corsOption()),
33
34
  ...globalMiddleares,
34
35
  ].forEach((middleware) => this.expressApp.use(middleware));
35
36
  this.passportMiddleware();
@@ -39,10 +40,15 @@ class Middleware {
39
40
  next();
40
41
  }));
41
42
  }
42
- defaultTemplatingEngine() {
43
- this.expressApp.engine("blade.html", Templating_engine_1.jsBladeEngine.render.bind(Templating_engine_1.jsBladeEngine));
44
- this.expressApp.set("views", `${this.rootPath}/resources/views`);
45
- this.expressApp.set("view engine", ".blade.html");
43
+ /**
44
+ * Default templating engine for the application.
45
+ * It sets up the Blade templating engine with the express app.
46
+ */
47
+ templatingEngine() {
48
+ const engine = this.app.config.engine || {};
49
+ this.expressApp.engine(engine.viewEngineExtension, engine.viewEngine);
50
+ this.expressApp.set("views", `${this.rootPath}/${engine.view}`);
51
+ this.expressApp.set("view engine", `${engine.viewEngineExtension}`);
46
52
  }
47
53
  passportMiddleware() {
48
54
  const passportAuth = new config_1.PassportAuth(this.app);
@@ -50,5 +56,8 @@ class Middleware {
50
56
  this.expressApp.use(passport_1.default.initialize());
51
57
  return this.expressApp.use(passport_1.default.session());
52
58
  }
59
+ corsOption() {
60
+ return this.app.config.cors || {};
61
+ }
53
62
  }
54
63
  exports.Middleware = Middleware;
@@ -158,7 +158,7 @@ class EngineHelpers extends expressions_1.TemplateRegex {
158
158
  ></script>`;
159
159
  }
160
160
  getAssetPath(resolvePath, beforeMatch, afterMatch, cssPath) {
161
- if (Config_1.config.get("APP_ENV") === "local") {
161
+ if (Config_1.config.get("APP_ENV") != "production") {
162
162
  const src = `${this.viteHost}/${resolvePath}`;
163
163
  return `${beforeMatch}${this.addScriptTag(src)}${afterMatch}`;
164
164
  }
@@ -181,7 +181,7 @@ class TemplatingEngine extends engineHelper_1.EngineHelpers {
181
181
  vite(content, match, param = this.option) {
182
182
  let { beforMatch, afterMatch } = this.content(content, match);
183
183
  const resourcePath = this.removeQuotes(match?.groups.resource || "").split(",");
184
- if (Config_1.config.get("APP_ENV") === "local" && resourcePath.length > 1) {
184
+ if (Config_1.config.get("APP_ENV") != "production" && resourcePath.length > 1) {
185
185
  beforMatch += this.addCSSLinkTag(`${this.viteHost}/${this.getResource(resourcePath, 0)}`);
186
186
  beforMatch += this.addScriptTag(this.viteHost + "/@vite/client");
187
187
  }
@@ -191,7 +191,7 @@ class TemplatingEngine extends engineHelper_1.EngineHelpers {
191
191
  viteReactRefresh(content, match, param) {
192
192
  const { beforMatch, afterMatch } = this.content(content, match);
193
193
  let viteClientRefresh = "";
194
- if (Config_1.config.get("APP_ENV") == "local") {
194
+ if (Config_1.config.get("APP_ENV") != "production") {
195
195
  viteClientRefresh = this.injectReactRefefresh();
196
196
  }
197
197
  return this.parser(beforMatch + viteClientRefresh + afterMatch);
@@ -60,4 +60,11 @@ export type AuthConfig = {
60
60
  export type AppConfig = {
61
61
  auth: AuthConfig;
62
62
  };
63
+ export type EngineConfig = {
64
+ templateEngine: string;
65
+ engine: string;
66
+ view: string;
67
+ viewEngine: () => any;
68
+ viewEngineExtension: string;
69
+ };
63
70
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Type/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAIrD,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAE9D,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAChB,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CA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,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,GAAG,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jcc-express-mvc",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "description": "express mvc structure",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",