jcc-express-mvc 1.9.1 → 1.9.3
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/index.d.ts +2 -4
- package/index.d.ts.map +10 -1
- package/index.js +194 -29
- package/lib/Application/ApplicationBuilder.d.ts +2 -1
- package/lib/Application/ApplicationBuilder.d.ts.map +1 -1
- package/lib/Application/ApplicationBuilder.js +2 -1
- package/lib/Auth/AuthMiddleware.d.ts.map +1 -1
- package/lib/Auth/AuthMiddleware.js +13 -6
- package/lib/Cache/index.d.ts +2 -0
- package/lib/Cache/index.d.ts.map +1 -1
- package/lib/Cache/index.js +101 -6
- package/lib/Cloudinary/CloudinaryServiceProvider.d.ts +5 -0
- package/lib/Cloudinary/CloudinaryServiceProvider.d.ts.map +1 -0
- package/lib/Cloudinary/CloudinaryServiceProvider.js +17 -0
- package/lib/Cloudinary/index.d.ts +20 -0
- package/lib/Cloudinary/index.d.ts.map +1 -0
- package/lib/Cloudinary/index.js +42 -0
- package/lib/Cloudinary/interface.d.ts +43 -0
- package/lib/Cloudinary/interface.d.ts.map +1 -0
- package/lib/Cloudinary/interface.js +2 -0
- package/lib/Cloudinary/type.d.ts +2 -0
- package/lib/Cloudinary/type.d.ts.map +1 -0
- package/lib/Cloudinary/type.js +2 -0
- package/lib/Command-Line/NodeArtisanCommand.d.ts +5 -0
- package/lib/Command-Line/NodeArtisanCommand.d.ts.map +1 -1
- package/lib/Command-Line/NodeArtisanCommand.js +55 -4
- package/lib/Command-Line/PublishCommand.d.ts.map +1 -1
- package/lib/Command-Line/PublishCommand.js +143 -6
- package/lib/Command-Line/WatchCommand.d.ts +12 -2
- package/lib/Command-Line/WatchCommand.d.ts.map +1 -1
- package/lib/Command-Line/WatchCommand.js +186 -45
- package/lib/Command-Line/files/CloudinaryConfigStub.d.ts +3 -0
- package/lib/Command-Line/files/CloudinaryConfigStub.d.ts.map +1 -0
- package/lib/Command-Line/files/CloudinaryConfigStub.js +22 -0
- package/lib/Command-Line/files/Controller.d.ts.map +1 -1
- package/lib/Command-Line/files/Controller.js +53 -51
- package/lib/Command-Line/files/Request.d.ts.map +1 -1
- package/lib/Command-Line/files/Request.js +0 -1
- package/lib/Error/AppErrorHandler.d.ts.map +1 -1
- package/lib/Error/AppErrorHandler.js +4 -0
- package/lib/Error/FileException/index.d.ts +4 -0
- package/lib/Error/FileException/index.d.ts.map +1 -0
- package/lib/Error/FileException/index.js +9 -0
- package/lib/Error/ModelExceptions/ModelTokenError.d.ts +4 -0
- package/lib/Error/ModelExceptions/ModelTokenError.d.ts.map +1 -0
- package/lib/Error/ModelExceptions/ModelTokenError.js +10 -0
- package/lib/Http/index.d.ts +3 -0
- package/lib/Http/index.d.ts.map +1 -1
- package/lib/Http/index.js +46 -10
- package/lib/Interface/index.d.ts +17 -1
- package/lib/Interface/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Model.d.ts +2 -0
- package/lib/Jcc-eloquent/lib/Model.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Model.js +13 -1
- package/lib/Mail/Manager.d.ts +2 -0
- package/lib/Mail/Manager.d.ts.map +1 -1
- package/lib/Mail/Manager.js +39 -2
- package/lib/Middleware/index.d.ts +1 -0
- package/lib/Middleware/index.d.ts.map +1 -1
- package/lib/Middleware/index.js +7 -2
- package/lib/Monitor/Collectors/CacheCollector.d.ts +2 -4
- package/lib/Monitor/Collectors/CacheCollector.d.ts.map +1 -1
- package/lib/Monitor/Collectors/CacheCollector.js +4 -63
- package/lib/Monitor/Collectors/CommandCollector.d.ts +3 -4
- package/lib/Monitor/Collectors/CommandCollector.d.ts.map +1 -1
- package/lib/Monitor/Collectors/CommandCollector.js +3 -4
- package/lib/Monitor/Collectors/DatabaseCollector.d.ts +2 -0
- package/lib/Monitor/Collectors/DatabaseCollector.d.ts.map +1 -1
- package/lib/Monitor/Collectors/DatabaseCollector.js +8 -1
- package/lib/Monitor/Collectors/MailCollector.d.ts +2 -4
- package/lib/Monitor/Collectors/MailCollector.d.ts.map +1 -1
- package/lib/Monitor/Collectors/MailCollector.js +5 -59
- package/lib/Monitor/Collectors/OutgoingRequestCollector.d.ts +3 -4
- package/lib/Monitor/Collectors/OutgoingRequestCollector.d.ts.map +1 -1
- package/lib/Monitor/Collectors/OutgoingRequestCollector.js +6 -8
- package/lib/Monitor/Collectors/ScheduleCollector.d.ts +2 -3
- package/lib/Monitor/Collectors/ScheduleCollector.d.ts.map +1 -1
- package/lib/Monitor/Collectors/ScheduleCollector.js +2 -3
- package/lib/Monitor/Controllers/MonitorController.d.ts +1 -0
- package/lib/Monitor/Controllers/MonitorController.d.ts.map +1 -1
- package/lib/Monitor/Controllers/MonitorController.js +15 -8
- package/lib/Monitor/MonitorManager.d.ts +10 -1
- package/lib/Monitor/MonitorManager.d.ts.map +1 -1
- package/lib/Monitor/MonitorManager.js +39 -1
- package/lib/Monitor/MonitorServiceProvider.d.ts.map +1 -1
- package/lib/Monitor/MonitorServiceProvider.js +3 -1
- package/lib/Monitor/index.d.ts +1 -0
- package/lib/Monitor/index.d.ts.map +1 -1
- package/lib/Monitor/index.js +1 -0
- package/lib/Monitor/types.d.ts +3 -1
- package/lib/Monitor/types.d.ts.map +1 -1
- package/lib/Monitor/types.js +13 -2
- package/lib/Queue/Queue.d.ts +4 -0
- package/lib/Queue/Queue.d.ts.map +1 -1
- package/lib/Queue/Queue.js +55 -0
- package/lib/Request/FormRequest.d.ts +13 -6
- package/lib/Request/FormRequest.d.ts.map +1 -1
- package/lib/Request/FormRequest.js +18 -7
- package/lib/Request/request.d.ts +2 -1
- package/lib/Request/request.d.ts.map +1 -1
- package/lib/Request/request.js +19 -0
- package/lib/Schedule/Scheduler.d.ts +2 -0
- package/lib/Schedule/Scheduler.d.ts.map +1 -1
- package/lib/Schedule/Scheduler.js +28 -1
- package/lib/Server/index.d.ts +2 -0
- package/lib/Server/index.d.ts.map +1 -1
- package/lib/Server/index.js +12 -1
- package/lib/Templating-engine/engineHelper.d.ts +2 -2
- package/lib/Templating-engine/engineHelper.d.ts.map +1 -1
- package/lib/Templating-engine/engineHelper.js +5 -2
- package/lib/Type/index.js +1 -0
- package/lib/util/index.d.ts +1 -2
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +31 -30
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
export { Authentication as Auth } from "./lib/Auth";
|
|
4
4
|
export { config } from "./lib/Config/Config";
|
|
5
|
+
export { SessionServiceProvider, SessionManager } from "./Core";
|
|
6
|
+
export type { SessionConfig } from "./lib/Interface";
|
|
5
7
|
export type {
|
|
6
8
|
AppRequest as Request,
|
|
7
9
|
AppResponse as Response,
|
|
8
10
|
AppNext as Next,
|
|
9
11
|
} from "./lib/Interface";
|
|
10
|
-
import { HttpContext as AppHttpContext } from "./lib/Interface";
|
|
11
12
|
export {
|
|
12
13
|
bcrypt,
|
|
13
14
|
verifyHash,
|
|
@@ -17,9 +18,7 @@ export {
|
|
|
17
18
|
assertProductionJwtSecret,
|
|
18
19
|
authSessionCookieOptions,
|
|
19
20
|
checkJwtAccessTokenPayload,
|
|
20
|
-
saveImage,
|
|
21
21
|
asyncHandler,
|
|
22
|
-
cloudinaryUpload,
|
|
23
22
|
rootPath,
|
|
24
23
|
} from "./lib/util";
|
|
25
24
|
export type { JwtAccessTokenPayloadResult } from "./lib/util";
|
|
@@ -57,5 +56,4 @@ export declare const auth: (
|
|
|
57
56
|
res: import("./lib/Interface").AppResponse,
|
|
58
57
|
next: import("./lib/Interface").AppNext,
|
|
59
58
|
) => Promise<void>;
|
|
60
|
-
export declare const httpContext: AppHttpContext;
|
|
61
59
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"file": "index.d.ts",
|
|
4
|
+
"sourceRoot": "",
|
|
5
|
+
"sources":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.d.ts" />
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.auth =
|
|
5
|
+
exports.apiAuth =
|
|
6
|
+
exports.guest =
|
|
7
|
+
exports.SocialiteOAuthUser =
|
|
8
|
+
exports.SlackProvider =
|
|
9
|
+
exports.TwitterProvider =
|
|
10
|
+
exports.GitLabProvider =
|
|
11
|
+
exports.FacebookProvider =
|
|
12
|
+
exports.GitHubProvider =
|
|
13
|
+
exports.GoogleProvider =
|
|
14
|
+
exports.resolveSocialiteConfig =
|
|
15
|
+
exports.SocialiteProvider =
|
|
16
|
+
exports.AbstractProvider =
|
|
17
|
+
exports.Socialite =
|
|
18
|
+
exports.registerRateLimit =
|
|
19
|
+
exports.loginRateLimit =
|
|
20
|
+
exports.rootPath =
|
|
21
|
+
exports.asyncHandler =
|
|
22
|
+
exports.checkJwtAccessTokenPayload =
|
|
23
|
+
exports.authSessionCookieOptions =
|
|
24
|
+
exports.assertProductionJwtSecret =
|
|
25
|
+
exports.jwtTokenType =
|
|
26
|
+
exports.jwtVerify =
|
|
27
|
+
exports.jwtSign =
|
|
28
|
+
exports.verifyHash =
|
|
29
|
+
exports.bcrypt =
|
|
30
|
+
exports.SessionManager =
|
|
31
|
+
exports.SessionServiceProvider =
|
|
32
|
+
exports.config =
|
|
33
|
+
exports.Auth =
|
|
34
|
+
void 0;
|
|
5
35
|
const AuthMiddleware_1 = require("./lib/Auth/AuthMiddleware");
|
|
6
36
|
var Auth_1 = require("./lib/Auth");
|
|
7
|
-
Object.defineProperty(exports, "Auth", {
|
|
37
|
+
Object.defineProperty(exports, "Auth", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () {
|
|
40
|
+
return Auth_1.Authentication;
|
|
41
|
+
},
|
|
42
|
+
});
|
|
8
43
|
var Config_1 = require("./lib/Config/Config");
|
|
9
|
-
Object.defineProperty(exports, "config", {
|
|
44
|
+
Object.defineProperty(exports, "config", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () {
|
|
47
|
+
return Config_1.config;
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
var Core_1 = require("./Core");
|
|
51
|
+
Object.defineProperty(exports, "SessionServiceProvider", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return Core_1.SessionServiceProvider;
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(exports, "SessionManager", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function () {
|
|
60
|
+
return Core_1.SessionManager;
|
|
61
|
+
},
|
|
62
|
+
});
|
|
10
63
|
var util_1 = require("./lib/util");
|
|
11
|
-
Object.defineProperty(exports, "bcrypt", {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Object.defineProperty(exports, "
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
64
|
+
Object.defineProperty(exports, "bcrypt", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () {
|
|
67
|
+
return util_1.bcrypt;
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(exports, "verifyHash", {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function () {
|
|
73
|
+
return util_1.verifyHash;
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(exports, "jwtSign", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return util_1.jwtSign;
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(exports, "jwtVerify", {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function () {
|
|
85
|
+
return util_1.jwtVerify;
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(exports, "jwtTokenType", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () {
|
|
91
|
+
return util_1.jwtTokenType;
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(exports, "assertProductionJwtSecret", {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: function () {
|
|
97
|
+
return util_1.assertProductionJwtSecret;
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(exports, "authSessionCookieOptions", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
get: function () {
|
|
103
|
+
return util_1.authSessionCookieOptions;
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(exports, "checkJwtAccessTokenPayload", {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
get: function () {
|
|
109
|
+
return util_1.checkJwtAccessTokenPayload;
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(exports, "asyncHandler", {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () {
|
|
115
|
+
return util_1.asyncHandler;
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(exports, "rootPath", {
|
|
119
|
+
enumerable: true,
|
|
120
|
+
get: function () {
|
|
121
|
+
return util_1.rootPath;
|
|
122
|
+
},
|
|
123
|
+
});
|
|
23
124
|
var loginRateLimit_1 = require("./lib/Auth/loginRateLimit");
|
|
24
|
-
Object.defineProperty(exports, "loginRateLimit", {
|
|
25
|
-
|
|
125
|
+
Object.defineProperty(exports, "loginRateLimit", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function () {
|
|
128
|
+
return loginRateLimit_1.loginRateLimit;
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
Object.defineProperty(exports, "registerRateLimit", {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function () {
|
|
134
|
+
return loginRateLimit_1.registerRateLimit;
|
|
135
|
+
},
|
|
136
|
+
});
|
|
26
137
|
var Socialite_1 = require("./lib/Socialite");
|
|
27
|
-
Object.defineProperty(exports, "Socialite", {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Object.defineProperty(exports, "
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
138
|
+
Object.defineProperty(exports, "Socialite", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function () {
|
|
141
|
+
return Socialite_1.Socialite;
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "AbstractProvider", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () {
|
|
147
|
+
return Socialite_1.AbstractProvider;
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
Object.defineProperty(exports, "SocialiteProvider", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function () {
|
|
153
|
+
return Socialite_1.SocialiteProvider;
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, "resolveSocialiteConfig", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function () {
|
|
159
|
+
return Socialite_1.resolveSocialiteConfig;
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(exports, "GoogleProvider", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function () {
|
|
165
|
+
return Socialite_1.GoogleProvider;
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, "GitHubProvider", {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function () {
|
|
171
|
+
return Socialite_1.GitHubProvider;
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
Object.defineProperty(exports, "FacebookProvider", {
|
|
175
|
+
enumerable: true,
|
|
176
|
+
get: function () {
|
|
177
|
+
return Socialite_1.FacebookProvider;
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperty(exports, "GitLabProvider", {
|
|
181
|
+
enumerable: true,
|
|
182
|
+
get: function () {
|
|
183
|
+
return Socialite_1.GitLabProvider;
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
Object.defineProperty(exports, "TwitterProvider", {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
get: function () {
|
|
189
|
+
return Socialite_1.TwitterProvider;
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
Object.defineProperty(exports, "SlackProvider", {
|
|
193
|
+
enumerable: true,
|
|
194
|
+
get: function () {
|
|
195
|
+
return Socialite_1.SlackProvider;
|
|
196
|
+
},
|
|
197
|
+
});
|
|
37
198
|
/** Laravel Socialite-style OAuth user profile (class with getters + `toPlainObject()`). */
|
|
38
199
|
var SocialUser_1 = require("./lib/Socialite/SocialUser");
|
|
39
|
-
Object.defineProperty(exports, "SocialiteOAuthUser", {
|
|
200
|
+
Object.defineProperty(exports, "SocialiteOAuthUser", {
|
|
201
|
+
enumerable: true,
|
|
202
|
+
get: function () {
|
|
203
|
+
return SocialUser_1.SocialUser;
|
|
204
|
+
},
|
|
205
|
+
});
|
|
40
206
|
exports.guest = AuthMiddleware_1.authMiddleware.guest;
|
|
41
207
|
exports.apiAuth = AuthMiddleware_1.authMiddleware.apiAuth;
|
|
42
208
|
exports.auth = AuthMiddleware_1.authMiddleware.auth;
|
|
43
|
-
exports.httpContext = {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Application } from "./Application";
|
|
2
2
|
import { ServiceProvider } from "../Providers/ServiceProvider";
|
|
3
3
|
import { RouteConfig } from "../Interface";
|
|
4
|
+
import { RequestHandler } from "express";
|
|
4
5
|
export declare class ApplicationBuilder {
|
|
5
6
|
app: Application;
|
|
6
7
|
constructor(app: Application);
|
|
@@ -11,7 +12,7 @@ export declare class ApplicationBuilder {
|
|
|
11
12
|
private withEvents;
|
|
12
13
|
private withBroadcasting;
|
|
13
14
|
withConsole(): this;
|
|
14
|
-
withMiddleware(): this;
|
|
15
|
+
withMiddleware(beforeAppMiddlewares?: RequestHandler[]): this;
|
|
15
16
|
create(): Application;
|
|
16
17
|
}
|
|
17
18
|
//# sourceMappingURL=ApplicationBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationBuilder.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Application/ApplicationBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ApplicationBuilder.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Application/ApplicationBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAU3C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,qBAAa,kBAAkB;IACtB,GAAG,EAAE,WAAW,CAAC;gBAEZ,GAAG,EAAE,WAAW;IAIrB,UAAU,CAAC,MAAM,EAAE,GAAG;IAKtB,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAMtC,WAAW,CAAC,WAAW,EAAE,WAAW,EAAE;IAOtC,aAAa,CAClB,SAAS,EAAE,KAAK,CAAC,KAAK,GAAG,EAAE,WAAW,KAAK,eAAe,CAAC;IA2B7D,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,gBAAgB;IAIjB,WAAW;IAKX,cAAc,CAAC,oBAAoB,GAAE,cAAc,EAAO;IAY1D,MAAM;CAKd"}
|
|
@@ -61,10 +61,11 @@ class ApplicationBuilder {
|
|
|
61
61
|
this.app.bind("ConsoleKernel", NodeArtisanCommand_1.ConsoleKernel);
|
|
62
62
|
return this;
|
|
63
63
|
}
|
|
64
|
-
withMiddleware() {
|
|
64
|
+
withMiddleware(beforeAppMiddlewares = []) {
|
|
65
65
|
//
|
|
66
66
|
const kernel = this.app.resolve("HttpKernel");
|
|
67
67
|
const middleware = new Middleware_1.Middleware(this.app);
|
|
68
|
+
middleware.runBeforeExpressMiddleware(beforeAppMiddlewares);
|
|
68
69
|
middleware.loadStaticFiles();
|
|
69
70
|
middleware.use(kernel.middlewares);
|
|
70
71
|
return this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthMiddleware.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Auth/AuthMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAUhE,cAAM,cAAc;IAClB,qCAAqC;IACxB,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"AuthMiddleware.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Auth/AuthMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAUhE,cAAM,cAAc;IAClB,qCAAqC;IACxB,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;IAkCxD,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;IAmC3D,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;CAgB9D;AAED,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
|
|
@@ -15,15 +15,22 @@ class AuthMiddleware {
|
|
|
15
15
|
if (!(0, util_1.checkJwtAccessTokenPayload)(payload).ok) {
|
|
16
16
|
return res.status(401).json({ message: "Not authorized" });
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const { exp, iat, typ, ...data } = payload;
|
|
19
|
+
const orm = Config_1.config.get("DB_ORM");
|
|
20
|
+
let user;
|
|
21
|
+
if (orm === "mongodb" || orm === "mongoose") {
|
|
22
|
+
user = await User.findOne({ ...data });
|
|
23
|
+
}
|
|
24
|
+
else if (orm === "sequelize") {
|
|
25
|
+
user = await User.findOne({ where: { ...data } });
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
user = await User.where({ ...data }).first();
|
|
29
|
+
}
|
|
23
30
|
if (!user)
|
|
24
31
|
return res.status(401).json({ message: "Not authorized" });
|
|
25
32
|
req.user = user;
|
|
26
|
-
req.id = String(id);
|
|
33
|
+
req.id = String(data?.id);
|
|
27
34
|
next();
|
|
28
35
|
}
|
|
29
36
|
catch (err) {
|
package/lib/Cache/index.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export declare class Cache {
|
|
|
23
23
|
pull<T = any>(key: string, fallback?: T | (() => T) | (() => Promise<T>)): Promise<T | null>;
|
|
24
24
|
add<T = any>(key: string, value: T, seconds?: number): Promise<boolean>;
|
|
25
25
|
tags(tags: string[]): TaggedCache;
|
|
26
|
+
private monitorCacheEnabled;
|
|
27
|
+
private recordCacheOp;
|
|
26
28
|
}
|
|
27
29
|
export { Cache as CacheManager };
|
|
28
30
|
export { CacheFacade, CacheFacde } from "./CacheFacade";
|
package/lib/Cache/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Cache/index.ts"],"names":[],"mappings":"AAA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&& this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.CacheFacde = exports.CacheFacade = exports.CacheManager = exports.Cache = void 0;
|
|
37
|
+
const Monitor_1 = require("../Monitor");
|
|
38
|
+
const MonitorManager_1 = require("../Monitor/MonitorManager");
|
|
37
39
|
const MemoryDriver_1 = require("./MemoryDriver");
|
|
38
40
|
const RedisDriver_1 = require("./RedisDriver");
|
|
39
41
|
const FileCacheDriver_1 = require("./FileCacheDriver");
|
|
40
42
|
const TaggedCache_1 = require("./TaggedCache");
|
|
41
43
|
const path = __importStar(require("path"));
|
|
44
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
42
45
|
// CacheDriver is imported from ../Interface
|
|
43
46
|
const fallbackCacheConfig = {
|
|
44
47
|
default: "memory",
|
|
@@ -106,10 +109,24 @@ class Cache {
|
|
|
106
109
|
if (!key) {
|
|
107
110
|
throw new Error("Cache key must be provided");
|
|
108
111
|
}
|
|
112
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
113
|
+
const storeName = this.config.default;
|
|
109
114
|
const value = await this.store().get(key);
|
|
110
115
|
if (value !== null && value !== undefined) {
|
|
116
|
+
this.recordCacheOp({
|
|
117
|
+
op: "hit",
|
|
118
|
+
key,
|
|
119
|
+
store: storeName,
|
|
120
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
121
|
+
});
|
|
111
122
|
return value;
|
|
112
123
|
}
|
|
124
|
+
this.recordCacheOp({
|
|
125
|
+
op: "miss",
|
|
126
|
+
key,
|
|
127
|
+
store: storeName,
|
|
128
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
129
|
+
});
|
|
113
130
|
if (fallback !== undefined) {
|
|
114
131
|
return typeof fallback === "function"
|
|
115
132
|
? await fallback()
|
|
@@ -127,16 +144,46 @@ class Cache {
|
|
|
127
144
|
if (seconds !== undefined && (isNaN(seconds) || seconds < 0)) {
|
|
128
145
|
throw new Error("Cache TTL must be a positive number");
|
|
129
146
|
}
|
|
130
|
-
|
|
147
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
148
|
+
await this.store().put(key, value, seconds);
|
|
149
|
+
this.recordCacheOp({
|
|
150
|
+
op: "write",
|
|
151
|
+
key,
|
|
152
|
+
store: this.config.default,
|
|
153
|
+
ttl: seconds,
|
|
154
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
155
|
+
});
|
|
131
156
|
}
|
|
132
157
|
async forget(key) {
|
|
133
|
-
|
|
158
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
159
|
+
const result = await this.store().forget(key);
|
|
160
|
+
this.recordCacheOp({
|
|
161
|
+
op: "forget",
|
|
162
|
+
key,
|
|
163
|
+
store: this.config.default,
|
|
164
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
165
|
+
});
|
|
166
|
+
return result;
|
|
134
167
|
}
|
|
135
168
|
async flush() {
|
|
136
|
-
|
|
169
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
170
|
+
await this.store().flush();
|
|
171
|
+
this.recordCacheOp({
|
|
172
|
+
op: "forget",
|
|
173
|
+
key: "*",
|
|
174
|
+
store: this.config.default,
|
|
175
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
176
|
+
});
|
|
137
177
|
}
|
|
138
178
|
async forever(key, value) {
|
|
139
|
-
|
|
179
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
180
|
+
await this.store().forever(key, value);
|
|
181
|
+
this.recordCacheOp({
|
|
182
|
+
op: "write",
|
|
183
|
+
key,
|
|
184
|
+
store: this.config.default,
|
|
185
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
186
|
+
});
|
|
140
187
|
}
|
|
141
188
|
async increment(key, value) {
|
|
142
189
|
return this.store().increment(key, value);
|
|
@@ -166,7 +213,27 @@ class Cache {
|
|
|
166
213
|
if (typeof callback !== "function") {
|
|
167
214
|
throw new Error("Callback must be a function");
|
|
168
215
|
}
|
|
169
|
-
|
|
216
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
217
|
+
const storeName = this.config.default;
|
|
218
|
+
const cached = await this.store().get(key);
|
|
219
|
+
if (cached !== null && cached !== undefined) {
|
|
220
|
+
this.recordCacheOp({
|
|
221
|
+
op: "hit",
|
|
222
|
+
key,
|
|
223
|
+
store: storeName,
|
|
224
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
225
|
+
});
|
|
226
|
+
return cached;
|
|
227
|
+
}
|
|
228
|
+
const result = await this.store().remember(key, seconds, callback);
|
|
229
|
+
this.recordCacheOp({
|
|
230
|
+
op: "write",
|
|
231
|
+
key,
|
|
232
|
+
store: storeName,
|
|
233
|
+
ttl: seconds,
|
|
234
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
235
|
+
});
|
|
236
|
+
return result;
|
|
170
237
|
}
|
|
171
238
|
// Laravel-like rememberForever method
|
|
172
239
|
async rememberForever(key, callback) {
|
|
@@ -176,7 +243,26 @@ class Cache {
|
|
|
176
243
|
if (typeof callback !== "function") {
|
|
177
244
|
throw new Error("Callback must be a function");
|
|
178
245
|
}
|
|
179
|
-
|
|
246
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
247
|
+
const storeName = this.config.default;
|
|
248
|
+
const cached = await this.store().get(key);
|
|
249
|
+
if (cached !== null && cached !== undefined) {
|
|
250
|
+
this.recordCacheOp({
|
|
251
|
+
op: "hit",
|
|
252
|
+
key,
|
|
253
|
+
store: storeName,
|
|
254
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
255
|
+
});
|
|
256
|
+
return cached;
|
|
257
|
+
}
|
|
258
|
+
const result = await this.store().rememberForever(key, callback);
|
|
259
|
+
this.recordCacheOp({
|
|
260
|
+
op: "write",
|
|
261
|
+
key,
|
|
262
|
+
store: storeName,
|
|
263
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
264
|
+
});
|
|
265
|
+
return result;
|
|
180
266
|
}
|
|
181
267
|
// Laravel-like pull method (get and forget)
|
|
182
268
|
async pull(key, fallback) {
|
|
@@ -198,6 +284,15 @@ class Cache {
|
|
|
198
284
|
tags(tags) {
|
|
199
285
|
return new TaggedCache_1.TaggedCache(this, tags);
|
|
200
286
|
}
|
|
287
|
+
monitorCacheEnabled() {
|
|
288
|
+
const mgr = MonitorManager_1.MonitorManager.getInstance();
|
|
289
|
+
return mgr.config.enabled && mgr.config.collectors.cache.enabled;
|
|
290
|
+
}
|
|
291
|
+
recordCacheOp(payload) {
|
|
292
|
+
if (!this.monitorCacheEnabled())
|
|
293
|
+
return;
|
|
294
|
+
Monitor_1.Monitor.recordCacheOp({ ...payload, timestamp: Date.now() });
|
|
295
|
+
}
|
|
201
296
|
}
|
|
202
297
|
exports.Cache = Cache;
|
|
203
298
|
exports.CacheManager = Cache;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloudinaryServiceProvider.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Cloudinary/CloudinaryServiceProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,qBAAa,yBAA0B,SAAQ,eAAe;IAE5D,QAAQ,IAAI,IAAI;CAQjB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudinaryServiceProvider = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const ServiceProvider_1 = require("../Providers/ServiceProvider");
|
|
6
|
+
class CloudinaryServiceProvider extends ServiceProvider_1.ServiceProvider {
|
|
7
|
+
//
|
|
8
|
+
register() {
|
|
9
|
+
//
|
|
10
|
+
const config = this.app.config.cloudinary;
|
|
11
|
+
if (!config) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
this.app.singleton(_1.Cloudinary.name, () => new _1.Cloudinary(config));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.CloudinaryServiceProvider = CloudinaryServiceProvider;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { UploadApiOptions, UploadApiResponse } from "cloudinary";
|
|
2
|
+
import { CloudinaryConfig, CloudinaryImageOptions } from "./interface";
|
|
3
|
+
export declare class Cloudinary {
|
|
4
|
+
constructor(config: CloudinaryConfig);
|
|
5
|
+
/**
|
|
6
|
+
* Upload file to Cloudinary
|
|
7
|
+
*/
|
|
8
|
+
upload(path: string, option?: UploadApiOptions): Promise<UploadApiResponse>;
|
|
9
|
+
/**
|
|
10
|
+
* Returns ONLY the URL (no HTML)
|
|
11
|
+
*/
|
|
12
|
+
url(publicId: string, options?: CloudinaryImageOptions): string;
|
|
13
|
+
/**
|
|
14
|
+
* Returns HTML <img> tag
|
|
15
|
+
*/
|
|
16
|
+
image(publicId: string, options?: CloudinaryImageOptions): string;
|
|
17
|
+
videoUrl(publicId: string, options?: CloudinaryImageOptions): string;
|
|
18
|
+
video(publicId: string, options?: any): string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Cloudinary/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEvE,qBAAa,UAAU;gBACT,MAAM,EAAE,gBAAgB;IASpC;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI3E;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM;IAI/D;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM;IAIjE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM;IAOpE,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,MAAM;CAG/C"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Cloudinary = void 0;
|
|
4
|
+
const cloudinary_1 = require("cloudinary");
|
|
5
|
+
class Cloudinary {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
cloudinary_1.v2.config({
|
|
8
|
+
cloud_name: config.cloud_name,
|
|
9
|
+
api_key: config.api_key,
|
|
10
|
+
api_secret: config.api_secret,
|
|
11
|
+
secure: true,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Upload file to Cloudinary
|
|
16
|
+
*/
|
|
17
|
+
upload(path, option) {
|
|
18
|
+
return cloudinary_1.v2.uploader.upload(path, option);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns ONLY the URL (no HTML)
|
|
22
|
+
*/
|
|
23
|
+
url(publicId, options) {
|
|
24
|
+
return cloudinary_1.v2.url(publicId, options);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns HTML <img> tag
|
|
28
|
+
*/
|
|
29
|
+
image(publicId, options) {
|
|
30
|
+
return cloudinary_1.v2.image(publicId, options);
|
|
31
|
+
}
|
|
32
|
+
videoUrl(publicId, options) {
|
|
33
|
+
return cloudinary_1.v2.url(publicId, {
|
|
34
|
+
resource_type: "video",
|
|
35
|
+
...options,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
video(publicId, options) {
|
|
39
|
+
return cloudinary_1.v2.video(publicId, options);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.Cloudinary = Cloudinary;
|