@ccci/micro-server 0.0.31 → 0.0.33
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/dist/index.js +15 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -87716,22 +87716,23 @@ var EXPIRY = process.env.JWT_EXPIRY ? process.env.JWT_EXPIRY : "30 days";
|
|
|
87716
87716
|
var ISSUER = process.env.JWT_ISSUER ? process.env.JWT_ISSUER : "*.service";
|
|
87717
87717
|
|
|
87718
87718
|
// src/utils/RouterFactory.ts
|
|
87719
|
-
var
|
|
87719
|
+
var UNSECURED_DIR = ["dev", "public"];
|
|
87720
87720
|
|
|
87721
87721
|
class RouterFactory {
|
|
87722
|
-
constructor(app, pathName, folderName = "routes") {
|
|
87722
|
+
constructor(app, pathName, folderName = "routes", context = "api") {
|
|
87723
87723
|
try {
|
|
87724
87724
|
fs2.readdirSync(folderName).forEach((dir) => {
|
|
87725
|
+
let isUnsecure = UNSECURED_DIR.findIndex((x) => x === dir) > -1;
|
|
87725
87726
|
var routerDir = path.join(folderName, dir);
|
|
87726
87727
|
fs2.readdirSync(routerDir).forEach((file) => {
|
|
87727
87728
|
let fullName = path.join(routerDir, file);
|
|
87728
87729
|
if (file.toLowerCase().indexOf(".js") || file.toLowerCase().indexOf(".ts")) {
|
|
87729
|
-
let fileName = fullName.replace(folderName,
|
|
87730
|
+
let fileName = fullName.replace(folderName, context).replace(".js", "").replace(".ts", "").split("\\").join("/");
|
|
87730
87731
|
let endpoint = `/${fileName}`;
|
|
87731
87732
|
let routeFile = `${pathName}/${fullName}`;
|
|
87732
87733
|
import(routeFile).then((routerClass) => {
|
|
87733
87734
|
let router = new routerClass.default;
|
|
87734
|
-
app.use(endpoint, (req, res, next) => this.authenticate(req, res, next, router.grantPublicAccess), router.getRoutes());
|
|
87735
|
+
app.use(endpoint, (req, res, next) => this.authenticate(req, res, next, isUnsecure || router.grantPublicAccess), router.getRoutes());
|
|
87735
87736
|
Logger.info(`Initializing endpoint: ${endpoint}`);
|
|
87736
87737
|
});
|
|
87737
87738
|
}
|
|
@@ -88260,6 +88261,16 @@ class BaseModel extends Model {
|
|
|
88260
88261
|
}
|
|
88261
88262
|
static getCommonAssociations() {
|
|
88262
88263
|
}
|
|
88264
|
+
static initialize(fields, name) {
|
|
88265
|
+
this.init({
|
|
88266
|
+
...fields,
|
|
88267
|
+
...this.getCommonAttributes()
|
|
88268
|
+
}, {
|
|
88269
|
+
sequelize: DatabaseConnector.getConnection(),
|
|
88270
|
+
tableName: name,
|
|
88271
|
+
paranoid: true
|
|
88272
|
+
});
|
|
88273
|
+
}
|
|
88263
88274
|
}
|
|
88264
88275
|
// src/decorators/Endpoints.ts
|
|
88265
88276
|
var endpoint = (target, methodName, descriptor) => {
|