jcc-express-mvc 1.8.7 → 1.8.21
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/Core/index.d.ts +4 -0
- package/Core/index.d.ts.map +1 -1
- package/Core/index.js +5 -0
- package/__tests__/Job.test.d.ts +2 -0
- package/__tests__/Job.test.d.ts.map +1 -0
- package/__tests__/Job.test.js +205 -0
- package/__tests__/MySqlSchemaBlueprint.test.d.ts +2 -0
- package/__tests__/MySqlSchemaBlueprint.test.d.ts.map +1 -0
- package/__tests__/MySqlSchemaBlueprint.test.js +55 -0
- package/__tests__/PostgresTranslator.test.d.ts +2 -0
- package/__tests__/PostgresTranslator.test.d.ts.map +1 -0
- package/__tests__/PostgresTranslator.test.js +82 -0
- package/__tests__/SQLiteTranslator.test.d.ts +2 -0
- package/__tests__/SQLiteTranslator.test.d.ts.map +1 -0
- package/__tests__/SQLiteTranslator.test.js +125 -0
- package/__tests__/SchemaAlterBlueprint.test.d.ts +2 -0
- package/__tests__/SchemaAlterBlueprint.test.d.ts.map +1 -0
- package/__tests__/SchemaAlterBlueprint.test.js +35 -0
- package/global.d.ts +3 -1
- package/index.d.ts +28 -3
- package/index.d.ts.map +1 -1
- package/index.js +33 -75
- package/lib/Application/Application.d.ts.map +1 -1
- package/lib/Application/Application.js +2 -2
- package/lib/Application/ApplicationBuilder.d.ts.map +1 -1
- package/lib/Application/ApplicationBuilder.js +22 -11
- package/lib/Auth/AuthMiddleware.d.ts.map +1 -1
- package/lib/Auth/AuthMiddleware.js +29 -12
- package/lib/Auth/index.d.ts +17 -3
- package/lib/Auth/index.d.ts.map +1 -1
- package/lib/Auth/index.js +128 -26
- package/lib/Auth/loginRateLimit.d.ts +6 -0
- package/lib/Auth/loginRateLimit.d.ts.map +1 -0
- package/lib/Auth/loginRateLimit.js +25 -0
- package/lib/Auth/refreshTokenStore.d.ts +24 -0
- package/lib/Auth/refreshTokenStore.d.ts.map +1 -0
- package/lib/Auth/refreshTokenStore.js +46 -0
- package/lib/Command-Line/DBCommand.d.ts.map +1 -1
- package/lib/Command-Line/DBCommand.js +9 -3
- package/lib/Command-Line/KeyGenerateCommand.d.ts +6 -0
- package/lib/Command-Line/KeyGenerateCommand.d.ts.map +1 -0
- package/lib/Command-Line/KeyGenerateCommand.js +47 -0
- package/lib/Command-Line/MakeCommand.d.ts +1 -0
- package/lib/Command-Line/MakeCommand.d.ts.map +1 -1
- package/lib/Command-Line/MakeCommand.js +36 -32
- package/lib/Command-Line/NodeArtisanCommand.d.ts +2 -0
- package/lib/Command-Line/NodeArtisanCommand.d.ts.map +1 -1
- package/lib/Command-Line/NodeArtisanCommand.js +24 -6
- package/lib/Command-Line/NodeTinker/Tinker.d.ts +5 -2
- package/lib/Command-Line/NodeTinker/Tinker.d.ts.map +1 -1
- package/lib/Command-Line/NodeTinker/Tinker.js +13 -3
- package/lib/Command-Line/WatchCommand.d.ts +29 -0
- package/lib/Command-Line/WatchCommand.d.ts.map +1 -0
- package/lib/Command-Line/WatchCommand.js +234 -0
- package/lib/Command-Line/files/Models.d.ts.map +1 -1
- package/lib/Command-Line/files/Models.js +67 -0
- package/lib/Console/Command.d.ts +18 -0
- package/lib/Console/Command.d.ts.map +1 -1
- package/lib/Console/Command.js +29 -0
- package/lib/Container/index.d.ts.map +1 -1
- package/lib/Container/index.js +22 -8
- package/lib/Database/Database.d.ts +21 -0
- package/lib/Database/Database.d.ts.map +1 -0
- package/lib/Database/Database.js +55 -0
- package/lib/Database/DatabaseServiceProvider.d.ts +22 -0
- package/lib/Database/DatabaseServiceProvider.d.ts.map +1 -0
- package/lib/Database/DatabaseServiceProvider.js +50 -0
- package/lib/Database/Drivers/KnexDriver.d.ts +13 -0
- package/lib/Database/Drivers/KnexDriver.d.ts.map +1 -0
- package/lib/Database/Drivers/KnexDriver.js +29 -0
- package/lib/Database/Drivers/MongooseDriver.d.ts +20 -0
- package/lib/Database/Drivers/MongooseDriver.d.ts.map +1 -0
- package/lib/Database/Drivers/MongooseDriver.js +57 -0
- package/lib/Database/Drivers/SequelizeDriver.d.ts +24 -0
- package/lib/Database/Drivers/SequelizeDriver.d.ts.map +1 -0
- package/lib/Database/Drivers/SequelizeDriver.js +82 -0
- package/lib/Database/index.d.ts +7 -0
- package/lib/Database/index.d.ts.map +1 -0
- package/lib/Database/index.js +11 -0
- package/lib/Database/interface.d.ts +14 -0
- package/lib/Database/interface.d.ts.map +1 -0
- package/lib/Database/interface.js +2 -0
- package/lib/Database/type.d.ts +18 -0
- package/lib/Database/type.d.ts.map +1 -0
- package/lib/Database/type.js +2 -0
- package/lib/Error/DisplayErrorCode.d.ts.map +1 -1
- package/lib/Error/DisplayErrorCode.js +27 -17
- package/lib/Error/MissMatchTokenException/index.d.ts +4 -0
- package/lib/Error/MissMatchTokenException/index.d.ts.map +1 -0
- package/lib/Error/MissMatchTokenException/index.js +9 -0
- package/lib/Error/SocialiteAuthError/SocialiteAuthError.d.ts +9 -0
- package/lib/Error/SocialiteAuthError/SocialiteAuthError.d.ts.map +1 -0
- package/lib/Error/SocialiteAuthError/SocialiteAuthError.js +17 -0
- package/lib/Global/helpers.d.ts.map +1 -1
- package/lib/Global/helpers.js +7 -6
- package/lib/Http/index.d.ts +3 -1
- package/lib/Http/index.d.ts.map +1 -1
- package/lib/Http/index.js +26 -5
- package/lib/Interface/index.d.ts +17 -3
- package/lib/Interface/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Builder.d.ts +12 -1
- package/lib/Jcc-eloquent/lib/Builder.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Builder.js +119 -5
- package/lib/Jcc-eloquent/lib/Database/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Database/index.js +2 -1
- package/lib/Jcc-eloquent/lib/Interfaces/index.d.ts +37 -2
- package/lib/Jcc-eloquent/lib/Interfaces/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Migration.d.ts +6 -0
- package/lib/Jcc-eloquent/lib/Migration.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Migration.js +24 -2
- package/lib/Jcc-eloquent/lib/Model.d.ts +24 -7
- package/lib/Jcc-eloquent/lib/Model.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Model.js +35 -2
- package/lib/Jcc-eloquent/lib/QueryBuilder.d.ts +2 -1
- package/lib/Jcc-eloquent/lib/QueryBuilder.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/QueryBuilder.js +10 -1
- package/lib/Jcc-eloquent/lib/Rollback.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Rollback.js +9 -2
- package/lib/Jcc-eloquent/lib/Schema/BaseSchemaEntity/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Schema/BaseSchemaEntity/index.js +3 -3
- package/lib/Jcc-eloquent/lib/Schema/BluePrint/index.d.ts +6 -2
- package/lib/Jcc-eloquent/lib/Schema/BluePrint/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Schema/BluePrint/index.js +41 -12
- package/lib/Jcc-eloquent/lib/Schema/Translator/Sqlite.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Schema/Translator/Sqlite.js +21 -3
- package/lib/Jcc-eloquent/lib/Schema/Translator/postgres.d.ts +1 -0
- package/lib/Jcc-eloquent/lib/Schema/Translator/postgres.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Schema/Translator/postgres.js +70 -14
- package/lib/Jcc-eloquent/lib/Schema/index.d.ts +12 -0
- package/lib/Jcc-eloquent/lib/Schema/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Schema/index.js +27 -6
- package/lib/Jcc-eloquent/lib/utils/index.d.ts +13 -0
- package/lib/Jcc-eloquent/lib/utils/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/utils/index.js +62 -0
- package/lib/Middleware/index.d.ts +1 -0
- package/lib/Middleware/index.d.ts.map +1 -1
- package/lib/Middleware/index.js +20 -8
- package/lib/Model/Sequelize.d.ts +3 -0
- package/lib/Model/Sequelize.d.ts.map +1 -0
- package/lib/Model/Sequelize.js +6 -0
- package/lib/Providers/RouteServiceProvider.d.ts.map +1 -1
- package/lib/Providers/RouteServiceProvider.js +3 -0
- package/lib/Providers/SessionServiceProvider.d.ts +12 -0
- package/lib/Providers/SessionServiceProvider.d.ts.map +1 -0
- package/lib/Providers/SessionServiceProvider.js +47 -0
- package/lib/Queue/Controllers/QueueControllers.d.ts +31 -0
- package/lib/Queue/Controllers/QueueControllers.d.ts.map +1 -0
- package/lib/Queue/Controllers/QueueControllers.js +126 -0
- package/lib/Queue/Drivers/DatabaseDriver.d.ts +6 -1
- package/lib/Queue/Drivers/DatabaseDriver.d.ts.map +1 -1
- package/lib/Queue/Drivers/DatabaseDriver.js +76 -21
- package/lib/Queue/Drivers/MemoryDriver.d.ts +17 -6
- package/lib/Queue/Drivers/MemoryDriver.d.ts.map +1 -1
- package/lib/Queue/Drivers/MemoryDriver.js +323 -14
- package/lib/Queue/Drivers/RedisDriver.d.ts +48 -0
- package/lib/Queue/Drivers/RedisDriver.d.ts.map +1 -0
- package/lib/Queue/Drivers/RedisDriver.js +533 -0
- package/lib/Queue/Job.d.ts +8 -0
- package/lib/Queue/Job.d.ts.map +1 -1
- package/lib/Queue/Job.js +25 -1
- package/lib/Queue/JobsLogger.d.ts.map +1 -1
- package/lib/Queue/JobsLogger.js +6 -3
- package/lib/Queue/Queue.d.ts +17 -0
- package/lib/Queue/Queue.d.ts.map +1 -1
- package/lib/Queue/Queue.js +146 -11
- package/lib/Queue/QueueServiceProvider.d.ts +6 -0
- package/lib/Queue/QueueServiceProvider.d.ts.map +1 -0
- package/lib/Queue/QueueServiceProvider.js +18 -0
- package/lib/Queue/Route/web.d.ts +2 -0
- package/lib/Queue/Route/web.d.ts.map +1 -0
- package/lib/Queue/Route/web.js +16 -0
- package/lib/Queue/index.d.ts +1 -0
- package/lib/Queue/index.d.ts.map +1 -1
- package/lib/Queue/index.js +3 -0
- package/lib/Queue/interface.d.ts +25 -0
- package/lib/Queue/interface.d.ts.map +1 -1
- package/lib/Queue/middleware/queueDashboardGuard.d.ts +7 -0
- package/lib/Queue/middleware/queueDashboardGuard.d.ts.map +1 -0
- package/lib/Queue/middleware/queueDashboardGuard.js +43 -0
- package/lib/Queue/type.d.ts +12 -1
- package/lib/Queue/type.d.ts.map +1 -1
- package/lib/Response/index.d.ts.map +1 -1
- package/lib/Response/index.js +6 -1
- package/lib/Routes/Route.d.ts +2 -2
- package/lib/Routes/Route.d.ts.map +1 -1
- package/lib/Routes/RouteBuilder.d.ts +2 -2
- package/lib/Routes/RouteBuilder.d.ts.map +1 -1
- package/lib/Security/CsrfMiddleware.d.ts +37 -0
- package/lib/Security/CsrfMiddleware.d.ts.map +1 -0
- package/lib/Security/CsrfMiddleware.js +85 -0
- package/lib/Security/MethodSpoofingMiddleware.d.ts +36 -0
- package/lib/Security/MethodSpoofingMiddleware.d.ts.map +1 -0
- package/lib/Security/MethodSpoofingMiddleware.js +51 -0
- package/lib/Security/index.d.ts +5 -0
- package/lib/Security/index.d.ts.map +1 -0
- package/lib/Security/index.js +7 -0
- package/lib/Session/DatabaseSession.d.ts +9 -3
- package/lib/Session/DatabaseSession.d.ts.map +1 -1
- package/lib/Session/DatabaseSession.js +38 -36
- package/lib/Session/ExpressJccSession.d.ts +23 -0
- package/lib/Session/ExpressJccSession.d.ts.map +1 -0
- package/lib/Session/ExpressJccSession.js +110 -0
- package/lib/Session/RedisSession.d.ts +2 -2
- package/lib/Session/RedisSession.d.ts.map +1 -1
- package/lib/Session/RedisSession.js +19 -5
- package/lib/Session/SessionManager.d.ts +18 -4
- package/lib/Session/SessionManager.d.ts.map +1 -1
- package/lib/Session/SessionManager.js +53 -17
- package/lib/Socialite/AbstractProvider.d.ts +60 -0
- package/lib/Socialite/AbstractProvider.d.ts.map +1 -0
- package/lib/Socialite/AbstractProvider.js +136 -0
- package/lib/Socialite/Drivers/facebook/FacebookDriver.d.ts +9 -0
- package/lib/Socialite/Drivers/facebook/FacebookDriver.d.ts.map +1 -0
- package/lib/Socialite/Drivers/facebook/FacebookDriver.js +40 -0
- package/lib/Socialite/Drivers/facebook/FacebookProvider.d.ts +15 -0
- package/lib/Socialite/Drivers/facebook/FacebookProvider.d.ts.map +1 -0
- package/lib/Socialite/Drivers/facebook/FacebookProvider.js +28 -0
- package/lib/Socialite/Drivers/github/GitHubDriver.d.ts +9 -0
- package/lib/Socialite/Drivers/github/GitHubDriver.d.ts.map +1 -0
- package/lib/Socialite/Drivers/github/GitHubDriver.js +54 -0
- package/lib/Socialite/Drivers/github/GitHubProvider.d.ts +15 -0
- package/lib/Socialite/Drivers/github/GitHubProvider.d.ts.map +1 -0
- package/lib/Socialite/Drivers/github/GitHubProvider.js +28 -0
- package/lib/Socialite/Drivers/gitlab/GitLabDriver.d.ts +10 -0
- package/lib/Socialite/Drivers/gitlab/GitLabDriver.d.ts.map +1 -0
- package/lib/Socialite/Drivers/gitlab/GitLabDriver.js +37 -0
- package/lib/Socialite/Drivers/gitlab/GitLabProvider.d.ts +15 -0
- package/lib/Socialite/Drivers/gitlab/GitLabProvider.d.ts.map +1 -0
- package/lib/Socialite/Drivers/gitlab/GitLabProvider.js +28 -0
- package/lib/Socialite/Drivers/google/GoogleDriver.d.ts +9 -0
- package/lib/Socialite/Drivers/google/GoogleDriver.d.ts.map +1 -0
- package/lib/Socialite/Drivers/google/GoogleDriver.js +39 -0
- package/lib/Socialite/Drivers/google/GoogleProvider.d.ts +15 -0
- package/lib/Socialite/Drivers/google/GoogleProvider.d.ts.map +1 -0
- package/lib/Socialite/Drivers/google/GoogleProvider.js +28 -0
- package/lib/Socialite/Drivers/slack/SlackDriver.d.ts +9 -0
- package/lib/Socialite/Drivers/slack/SlackDriver.d.ts.map +1 -0
- package/lib/Socialite/Drivers/slack/SlackDriver.js +41 -0
- package/lib/Socialite/Drivers/slack/SlackProvider.d.ts +16 -0
- package/lib/Socialite/Drivers/slack/SlackProvider.d.ts.map +1 -0
- package/lib/Socialite/Drivers/slack/SlackProvider.js +37 -0
- package/lib/Socialite/Drivers/twitter/TwitterDriver.d.ts +9 -0
- package/lib/Socialite/Drivers/twitter/TwitterDriver.d.ts.map +1 -0
- package/lib/Socialite/Drivers/twitter/TwitterDriver.js +57 -0
- package/lib/Socialite/Drivers/twitter/TwitterProvider.d.ts +16 -0
- package/lib/Socialite/Drivers/twitter/TwitterProvider.d.ts.map +1 -0
- package/lib/Socialite/Drivers/twitter/TwitterProvider.js +38 -0
- package/lib/Socialite/SocialUser.d.ts +42 -0
- package/lib/Socialite/SocialUser.d.ts.map +1 -0
- package/lib/Socialite/SocialUser.js +116 -0
- package/lib/Socialite/Socialite.d.ts +13 -0
- package/lib/Socialite/Socialite.d.ts.map +1 -0
- package/lib/Socialite/Socialite.js +41 -0
- package/lib/Socialite/SocialiteProvider.d.ts +9 -0
- package/lib/Socialite/SocialiteProvider.d.ts.map +1 -0
- package/lib/Socialite/SocialiteProvider.js +15 -0
- package/lib/Socialite/config.d.ts +7 -0
- package/lib/Socialite/config.d.ts.map +1 -0
- package/lib/Socialite/config.js +44 -0
- package/lib/Socialite/constant.d.ts +18 -0
- package/lib/Socialite/constant.d.ts.map +1 -0
- package/lib/Socialite/constant.js +20 -0
- package/lib/Socialite/index.d.ts +13 -0
- package/lib/Socialite/index.d.ts.map +1 -0
- package/lib/Socialite/index.js +25 -0
- package/lib/Socialite/types.d.ts +13 -0
- package/lib/Socialite/types.d.ts.map +1 -0
- package/lib/Socialite/types.js +2 -0
- package/lib/Templating-engine/benchmark.d.ts +7 -0
- package/lib/Templating-engine/benchmark.d.ts.map +1 -0
- package/lib/Templating-engine/benchmark.js +44 -0
- package/lib/Templating-engine/engineHelper.d.ts +37 -8
- package/lib/Templating-engine/engineHelper.d.ts.map +1 -1
- package/lib/Templating-engine/engineHelper.js +203 -26
- package/lib/Templating-engine/errors.d.ts +15 -0
- package/lib/Templating-engine/errors.d.ts.map +1 -0
- package/lib/Templating-engine/errors.js +35 -0
- package/lib/Templating-engine/expressions.d.ts +24 -0
- package/lib/Templating-engine/expressions.d.ts.map +1 -1
- package/lib/Templating-engine/expressions.js +27 -5
- package/lib/Templating-engine/index.d.ts +87 -17
- package/lib/Templating-engine/index.d.ts.map +1 -1
- package/lib/Templating-engine/index.js +701 -96
- package/lib/Templating-engine/plugins.d.ts +30 -0
- package/lib/Templating-engine/plugins.d.ts.map +1 -0
- package/lib/Templating-engine/plugins.js +47 -0
- package/lib/Type/index.d.ts +1 -0
- package/lib/Type/index.d.ts.map +1 -1
- package/lib/Validation/Validator/CustomValidation.d.ts.map +1 -1
- package/lib/Validation/Validator/CustomValidation.js +2 -2
- package/lib/Validation/Validator/helper.d.ts.map +1 -1
- package/lib/Validation/Validator/helper.js +8 -1
- package/lib/util/index.d.ts +42 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +154 -17
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DatabaseDriver } from "../interface";
|
|
2
|
+
/** Mongoose connection type - loaded dynamically to avoid hard dependency */
|
|
3
|
+
type MongooseConnection = any;
|
|
4
|
+
/**
|
|
5
|
+
* Mongoose driver for MongoDB.
|
|
6
|
+
* Requires: npm install mongoose
|
|
7
|
+
* Uses MONGODB_URI from .env or constructs from DB_* variables.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MongooseDriver implements DatabaseDriver {
|
|
10
|
+
private config;
|
|
11
|
+
private connection;
|
|
12
|
+
private connected;
|
|
13
|
+
constructor(config: any);
|
|
14
|
+
connect(): Promise<void>;
|
|
15
|
+
private buildUri;
|
|
16
|
+
getConnection(): MongooseConnection;
|
|
17
|
+
disconnect(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=MongooseDriver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MongooseDriver.d.ts","sourceRoot":"","sources":["../../../../jcc-express-mvc/lib/Database/Drivers/MongooseDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,6EAA6E;AAC7E,KAAK,kBAAkB,GAAG,GAAG,CAAC;AAE9B;;;;GAIG;AACH,qBAAa,cAAe,YAAW,cAAc;IAIvC,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,UAAU,CAAmC;IACrD,OAAO,CAAC,SAAS,CAAS;gBAEN,MAAM,EAAE,GAAG;IAIzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B9B,OAAO,CAAC,QAAQ;IAehB,aAAa,IAAI,kBAAkB;IAO7B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAOlC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongooseDriver = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Mongoose driver for MongoDB.
|
|
6
|
+
* Requires: npm install mongoose
|
|
7
|
+
* Uses MONGODB_URI from .env or constructs from DB_* variables.
|
|
8
|
+
*/
|
|
9
|
+
class MongooseDriver {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.connection = null;
|
|
13
|
+
this.connected = false;
|
|
14
|
+
this.config = config;
|
|
15
|
+
}
|
|
16
|
+
async connect() {
|
|
17
|
+
if (this.connected && this.connection)
|
|
18
|
+
return;
|
|
19
|
+
try {
|
|
20
|
+
const mongoose = require("mongoose");
|
|
21
|
+
const uri = this.buildUri(this.config.host, this.config.port, this.config.database, this.config.username, this.config.password);
|
|
22
|
+
this.connection = await mongoose.connect(this.config.mongoUri || uri, {
|
|
23
|
+
...(this.config.options && typeof this.config.options === "object"
|
|
24
|
+
? this.config.options
|
|
25
|
+
: {}),
|
|
26
|
+
});
|
|
27
|
+
this.connected = true;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
throw new Error(`Mongoose connection failed. Install: npm install mongoose. ${error.message}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
buildUri(host, port, database, username, password) {
|
|
34
|
+
if (!host || !database)
|
|
35
|
+
return "";
|
|
36
|
+
const auth = username && password ? `${username}:${password}@` : "";
|
|
37
|
+
if (auth) {
|
|
38
|
+
return `mongodb+srv://${auth}${host}:${port}/${database}`;
|
|
39
|
+
}
|
|
40
|
+
return `mongodb://${auth}${host}:${port}/${database}`;
|
|
41
|
+
}
|
|
42
|
+
getConnection() {
|
|
43
|
+
if (!this.connection) {
|
|
44
|
+
throw new Error("Database not connected. Call connect() first.");
|
|
45
|
+
}
|
|
46
|
+
return this.connection;
|
|
47
|
+
}
|
|
48
|
+
async disconnect() {
|
|
49
|
+
if (!this.connected || !this.connection)
|
|
50
|
+
return;
|
|
51
|
+
const mongoose = require("mongoose");
|
|
52
|
+
await mongoose.disconnect();
|
|
53
|
+
this.connection = null;
|
|
54
|
+
this.connected = false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.MongooseDriver = MongooseDriver;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DatabaseDriver } from "../interface";
|
|
2
|
+
/** Sequelize instance type - loaded dynamically to avoid hard dependency */
|
|
3
|
+
type SequelizeInstance = any;
|
|
4
|
+
/**
|
|
5
|
+
* Sequelize driver for SQL databases via Sequelize ORM.
|
|
6
|
+
* Requires: npm install sequelize mysql2 (or pg2, sqlite3, etc.)
|
|
7
|
+
*/
|
|
8
|
+
export declare class SequelizeDriver implements DatabaseDriver {
|
|
9
|
+
private config;
|
|
10
|
+
private sequelize;
|
|
11
|
+
private connected;
|
|
12
|
+
private static instance;
|
|
13
|
+
constructor(config: any);
|
|
14
|
+
connect(): Promise<SequelizeInstance>;
|
|
15
|
+
getConnection(): SequelizeInstance;
|
|
16
|
+
disconnect(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Load Sequelize models from app/Models and sync tables
|
|
19
|
+
*/
|
|
20
|
+
private loadModelsIfSequelize;
|
|
21
|
+
static getSequelizeInstance(): SequelizeInstance;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=SequelizeDriver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SequelizeDriver.d.ts","sourceRoot":"","sources":["../../../../jcc-express-mvc/lib/Database/Drivers/SequelizeDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAK9C,4EAA4E;AAC5E,KAAK,iBAAiB,GAAG,GAAG,CAAC;AAE7B;;;GAGG;AACH,qBAAa,eAAgB,YAAW,cAAc;IAKxC,OAAO,CAAC,MAAM;IAJ1B,OAAO,CAAC,SAAS,CAAkC;IACnD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAgC;gBAEnC,MAAM,EAAE,GAAG;IAKzB,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC;IA8B3C,aAAa,IAAI,iBAAiB;IAO5B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAOjC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAmB7B,MAAM,CAAC,oBAAoB,IAAI,iBAAiB;CAGjD"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SequelizeDriver = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const app_root_path_1 = __importDefault(require("app-root-path"));
|
|
10
|
+
/**
|
|
11
|
+
* Sequelize driver for SQL databases via Sequelize ORM.
|
|
12
|
+
* Requires: npm install sequelize mysql2 (or pg2, sqlite3, etc.)
|
|
13
|
+
*/
|
|
14
|
+
class SequelizeDriver {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.sequelize = null;
|
|
18
|
+
this.connected = false;
|
|
19
|
+
this.config = config;
|
|
20
|
+
// console.log(this.app);
|
|
21
|
+
}
|
|
22
|
+
async connect() {
|
|
23
|
+
if (this.connected && this.sequelize)
|
|
24
|
+
return;
|
|
25
|
+
try {
|
|
26
|
+
const { Sequelize } = require("sequelize");
|
|
27
|
+
this.sequelize = new Sequelize(this.config.database, this.config.username, this.config.password, {
|
|
28
|
+
...this.config.options,
|
|
29
|
+
});
|
|
30
|
+
await this.sequelize.authenticate();
|
|
31
|
+
//
|
|
32
|
+
this.loadModelsIfSequelize();
|
|
33
|
+
this.sequelize.sync({ ...this.config.sync });
|
|
34
|
+
if (this.config.dropTables) {
|
|
35
|
+
await this.sequelize.drop();
|
|
36
|
+
}
|
|
37
|
+
this.connected = true;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw new Error(`Sequelize connection failed. Install: npm install sequelize mysql2. ${error.message}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
getConnection() {
|
|
44
|
+
if (!this.sequelize) {
|
|
45
|
+
throw new Error("Database not connected. Call connect() first.");
|
|
46
|
+
}
|
|
47
|
+
return this.sequelize;
|
|
48
|
+
}
|
|
49
|
+
async disconnect() {
|
|
50
|
+
if (!this.connected || !this.sequelize)
|
|
51
|
+
return;
|
|
52
|
+
await this.sequelize.close();
|
|
53
|
+
this.sequelize = null;
|
|
54
|
+
this.connected = false;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Load Sequelize models from app/Models and sync tables
|
|
58
|
+
*/
|
|
59
|
+
loadModelsIfSequelize() {
|
|
60
|
+
let models = {};
|
|
61
|
+
const modelsPath = path_1.default.join(app_root_path_1.default.path, "app", "Models");
|
|
62
|
+
fs_1.default.readdirSync(modelsPath)
|
|
63
|
+
.filter((f) => f.endsWith(".js") || f.endsWith(".ts"))
|
|
64
|
+
.sort()
|
|
65
|
+
.forEach((file) => {
|
|
66
|
+
const name = path_1.default.parse(file).name;
|
|
67
|
+
const getModel = require(path_1.default.join(modelsPath, file));
|
|
68
|
+
models[name] = getModel[name];
|
|
69
|
+
});
|
|
70
|
+
Object.keys(models).forEach((modelName) => {
|
|
71
|
+
if (models[modelName].associate) {
|
|
72
|
+
models[modelName].associate(models);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
static getSequelizeInstance() {
|
|
77
|
+
return this.instance;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.SequelizeDriver = SequelizeDriver;
|
|
81
|
+
SequelizeDriver.instance = null;
|
|
82
|
+
// export const sequelize = SequelizeDriver.getSequelizeInstance();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Database } from "./Database";
|
|
2
|
+
export { DatabaseDriver } from "./interface";
|
|
3
|
+
export type { DatabaseConfig, DatabaseDriverName } from "./type";
|
|
4
|
+
export { KnexDriver } from "./Drivers/KnexDriver";
|
|
5
|
+
export { SequelizeDriver } from "./Drivers/SequelizeDriver";
|
|
6
|
+
export { MongooseDriver } from "./Drivers/MongooseDriver";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Database/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongooseDriver = exports.SequelizeDriver = exports.KnexDriver = exports.Database = void 0;
|
|
4
|
+
var Database_1 = require("./Database");
|
|
5
|
+
Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return Database_1.Database; } });
|
|
6
|
+
var KnexDriver_1 = require("./Drivers/KnexDriver");
|
|
7
|
+
Object.defineProperty(exports, "KnexDriver", { enumerable: true, get: function () { return KnexDriver_1.KnexDriver; } });
|
|
8
|
+
var SequelizeDriver_1 = require("./Drivers/SequelizeDriver");
|
|
9
|
+
Object.defineProperty(exports, "SequelizeDriver", { enumerable: true, get: function () { return SequelizeDriver_1.SequelizeDriver; } });
|
|
10
|
+
var MongooseDriver_1 = require("./Drivers/MongooseDriver");
|
|
11
|
+
Object.defineProperty(exports, "MongooseDriver", { enumerable: true, get: function () { return MongooseDriver_1.MongooseDriver; } });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base interface for database drivers.
|
|
3
|
+
* Each driver (Knex/Jcc-eloquent, Sequelize, Mongoose) implements this to provide
|
|
4
|
+
* a unified connection lifecycle. Use getConnection() for ORM-specific APIs.
|
|
5
|
+
*/
|
|
6
|
+
export interface DatabaseDriver {
|
|
7
|
+
/** Establish connection to the database */
|
|
8
|
+
connect(): Promise<void>;
|
|
9
|
+
/** Return the underlying client (Knex, Sequelize, or Mongoose connection) */
|
|
10
|
+
getConnection(): unknown;
|
|
11
|
+
/** Close the database connection */
|
|
12
|
+
disconnect(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Database/interface.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB,6EAA6E;IAC7E,aAAa,IAAI,OAAO,CAAC;IAEzB,oCAAoC;IACpC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type DatabaseDriverName = "knex" | "sequelize" | "mongoose" | "sqlite" | "better-sqlite3" | "postgres" | "postgress" | "pg" | "mysql2" | "mysql" | "pg2" | "mongodb";
|
|
2
|
+
export interface DatabaseConfig {
|
|
3
|
+
driver: DatabaseDriverName;
|
|
4
|
+
/** Connection name for config lookup (e.g. "mysql", "default") */
|
|
5
|
+
connection?: string;
|
|
6
|
+
host?: string;
|
|
7
|
+
port?: number;
|
|
8
|
+
database?: string;
|
|
9
|
+
username?: string;
|
|
10
|
+
password?: string;
|
|
11
|
+
/** For SQLite */
|
|
12
|
+
filename?: string;
|
|
13
|
+
/** MongoDB connection URI (used by Mongoose) */
|
|
14
|
+
uri?: string;
|
|
15
|
+
/** Sequelize/Mongoose options passthrough */
|
|
16
|
+
options?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Database/type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,WAAW,GACX,UAAU,GACV,QAAQ,GACR,gBAAgB,GAChB,UAAU,GACV,WAAW,GACX,IAAI,GACJ,QAAQ,GACR,OAAO,GACP,KAAK,GACL,SAAS,CAAC;AACd,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisplayErrorCode.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Error/DisplayErrorCode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEvD,qBAAa,YAAa,SAAQ,gBAAgB;IAChD;;OAEG;IACH,MAAM,CAAC,IAAI,CACT,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,GAAG,EACZ,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,UAAU;
|
|
1
|
+
{"version":3,"file":"DisplayErrorCode.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Error/DisplayErrorCode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEvD,qBAAa,YAAa,SAAQ,gBAAgB;IAChD;;OAEG;IACH,MAAM,CAAC,IAAI,CACT,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,GAAG,EACZ,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,UAAU;IAyEjB,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG;CAGxD"}
|
|
@@ -12,26 +12,33 @@ class DisplayError extends ErrorHighlight_1.ErrorHighLighter {
|
|
|
12
12
|
*/
|
|
13
13
|
static show(errorPath, message, res, req) {
|
|
14
14
|
try {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
let startLine
|
|
19
|
-
let endLine
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
const cleaned = errorPath.replace(/\(|\)/g, "").trim();
|
|
16
|
+
const lineMatch = cleaned.match(/(\d+):(\d+)$/);
|
|
17
|
+
let fullPath;
|
|
18
|
+
let startLine;
|
|
19
|
+
let endLine;
|
|
20
|
+
if (lineMatch) {
|
|
21
|
+
fullPath = cleaned
|
|
22
|
+
.slice(0, cleaned.length - lineMatch[0].length)
|
|
23
|
+
.replace(/[\s:]+$/, "")
|
|
24
|
+
.trim();
|
|
25
|
+
startLine = Math.max(1, Number(lineMatch[1]) || 1);
|
|
26
|
+
endLine = Math.max(startLine, Number(lineMatch[2]) || startLine);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
fullPath = cleaned;
|
|
30
|
+
startLine = 1;
|
|
31
|
+
endLine = 1;
|
|
32
|
+
}
|
|
24
33
|
if (startLine > endLine) {
|
|
25
|
-
[startLine, endLine] = [endLine, startLine];
|
|
34
|
+
[startLine, endLine] = [endLine, startLine];
|
|
26
35
|
}
|
|
27
|
-
// If API request → send JSON response
|
|
28
36
|
if (req.expectsJson() && !req.isInertia()) {
|
|
29
37
|
return res.status(500).json({
|
|
30
|
-
stack:
|
|
38
|
+
stack: fullPath.trim() + ` on line ${startLine}:${endLine}`,
|
|
31
39
|
error: ` ${message} `,
|
|
32
40
|
});
|
|
33
41
|
}
|
|
34
|
-
const fullPath = pathParts.join("/");
|
|
35
42
|
const code = fs_1.default.readFileSync(fullPath, "utf8");
|
|
36
43
|
const content = code.split(/\n/g);
|
|
37
44
|
// console.log("Total lines in file:", content.length);
|
|
@@ -46,16 +53,19 @@ class DisplayError extends ErrorHighlight_1.ErrorHighLighter {
|
|
|
46
53
|
const formattedContent = snippet
|
|
47
54
|
.map((line, i) => `${from + i + 1}. ${line}`)
|
|
48
55
|
.join("\n");
|
|
49
|
-
const
|
|
56
|
+
const errorLineInSnippet = startLine - from;
|
|
57
|
+
const html = this.renderHtml(formattedContent, errorLineInSnippet, `
|
|
50
58
|
<p class='py-2 text-red'>${message.trim()}</p>
|
|
51
59
|
<p class='p-2 text-sm'> ${fullPath.trim()} ${startLine}:${endLine} </p>
|
|
52
60
|
`);
|
|
53
61
|
return res.status(500).send(html);
|
|
54
62
|
}
|
|
55
63
|
catch (error) {
|
|
56
|
-
return res
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
return res.status(500).json({
|
|
65
|
+
message: "Internal Error",
|
|
66
|
+
error: error.message,
|
|
67
|
+
stack: error.stack,
|
|
68
|
+
});
|
|
59
69
|
}
|
|
60
70
|
}
|
|
61
71
|
static renderHtml(code, line, message) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../jcc-express-mvc/lib/Error/MissMatchTokenException/index.ts"],"names":[],"mappings":"AAAA,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAG5B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MissMatchTokenException = void 0;
|
|
4
|
+
class MissMatchTokenException extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.MissMatchTokenException = MissMatchTokenException;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocialiteAuthError.d.ts","sourceRoot":"","sources":["../../../../jcc-express-mvc/lib/Error/SocialiteAuthError/SocialiteAuthError.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,OAAO,CAAC,QAAQ,CAAS;IACzB;;OAEG;gBACS,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAoB;IAMpD,WAAW,IAAI,MAAM;CAG7B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SocialiteAuthError = void 0;
|
|
4
|
+
class SocialiteAuthError extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* @param {string} message
|
|
7
|
+
*/
|
|
8
|
+
constructor(message, provider = "socialite") {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "SocialiteAuthError";
|
|
11
|
+
this.provider = provider;
|
|
12
|
+
}
|
|
13
|
+
getProvider() {
|
|
14
|
+
return this.provider;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.SocialiteAuthError = SocialiteAuthError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Global/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Global/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAmBzD,eAAO,MAAM,aAAa,GAAI,KAAK,WAAW,SAqH7C,CAAC"}
|
package/lib/Global/helpers.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.globalHelpers = void 0;
|
|
4
|
-
const Application_1 = require("../Application/Application");
|
|
5
4
|
const Config_1 = require("../Config/Config");
|
|
6
5
|
const Event_1 = require("../Event/Event");
|
|
7
6
|
const Str_1 = require("../util/Str");
|
|
8
7
|
const util_1 = require("../util");
|
|
9
8
|
const Authorization_1 = require("../Authorization");
|
|
10
9
|
const Date_1 = require("../Date");
|
|
10
|
+
const index_1 = require("../Auth/index");
|
|
11
11
|
const globalHelpers = (app) => {
|
|
12
|
-
|
|
12
|
+
(0, util_1.assertProductionJwtSecret)();
|
|
13
|
+
globalThis.app = app;
|
|
13
14
|
//
|
|
14
15
|
globalThis.env = (key, defaultValue) => {
|
|
15
16
|
return Config_1.config.get(key, defaultValue);
|
|
@@ -53,7 +54,7 @@ const globalHelpers = (app) => {
|
|
|
53
54
|
return app.resolve("next");
|
|
54
55
|
};
|
|
55
56
|
globalThis.auth = () => {
|
|
56
|
-
return
|
|
57
|
+
return index_1.Authentication;
|
|
57
58
|
};
|
|
58
59
|
globalThis.validate = async (validation, customMessages) => {
|
|
59
60
|
return (app
|
|
@@ -75,11 +76,11 @@ const globalHelpers = (app) => {
|
|
|
75
76
|
? app.resolve("response")["redirect"](url)
|
|
76
77
|
: app.resolve("response")["redirectBack"]();
|
|
77
78
|
};
|
|
78
|
-
globalThis.auth = () => {
|
|
79
|
-
return app.resolve("request")?.user;
|
|
80
|
-
};
|
|
81
79
|
globalThis.now = (date = new Date()) => {
|
|
82
80
|
return new Date_1.Carbon(date);
|
|
83
81
|
};
|
|
82
|
+
globalThis.session = () => {
|
|
83
|
+
return app.resolve("request")?.jccSession;
|
|
84
|
+
};
|
|
84
85
|
};
|
|
85
86
|
exports.globalHelpers = globalHelpers;
|
package/lib/Http/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class Http extends HttpHeaders {
|
|
|
7
7
|
private static body;
|
|
8
8
|
private static resolveParam;
|
|
9
9
|
static get(url: string, params?: Record<string, any>): Promise<axios.AxiosResponse<any, any, {}>>;
|
|
10
|
-
static post(url: string, data?: Record<string, any>): Promise<axios.AxiosResponse<any, any, {}>>;
|
|
10
|
+
static post(url: string, data?: Record<string, any> | string): Promise<axios.AxiosResponse<any, any, {}>>;
|
|
11
11
|
static withQueryParameters(params?: Record<string, any>): typeof Http;
|
|
12
12
|
static withBody(data?: Record<string, any>, contentType?: string): typeof Http;
|
|
13
13
|
static patch(url: string, data?: Record<string, any>): Promise<axios.AxiosResponse<any, any, {}>>;
|
|
@@ -17,5 +17,7 @@ export declare class Http extends HttpHeaders {
|
|
|
17
17
|
static delete(url: string): Promise<axios.AxiosResponse<any, any, {}>>;
|
|
18
18
|
static accept(content: string): typeof Http;
|
|
19
19
|
static acceptJson(): typeof Http;
|
|
20
|
+
/** Clear fluent state so chained headers/query/body do not leak across requests. */
|
|
21
|
+
static reset(): typeof Http;
|
|
20
22
|
}
|
|
21
23
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/Http/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Http/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,qBAAa,IAAK,SAAQ,WAAW;IAEnC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAuB;IAG3C,OAAO,CAAC,MAAM,CAAC,WAAW,CAA2B;IAGrD,OAAO,CAAC,MAAM,CAAC,OAAO,CAA2B;IAGjD,OAAO,CAAC,MAAM,CAAC,IAAI,CAA2B;IAG9C,OAAO,CAAC,MAAM,CAAC,YAAY;IAO3B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Http/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,qBAAa,IAAK,SAAQ,WAAW;IAEnC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAuB;IAG3C,OAAO,CAAC,MAAM,CAAC,WAAW,CAA2B;IAGrD,OAAO,CAAC,MAAM,CAAC,OAAO,CAA2B;IAGjD,OAAO,CAAC,MAAM,CAAC,IAAI,CAA2B;IAG9C,OAAO,CAAC,MAAM,CAAC,YAAY;IAO3B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAQxD,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAW;IAQhE,MAAM,CAAC,mBAAmB,CAAC,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAK3D,MAAM,CAAC,QAAQ,CACb,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAC9B,WAAW,SAA2B;IAOxC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAQxD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAK/C,MAAM,CAAC,MAAM;IAIb,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAQtD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM;IAQzB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM;IAK7B,MAAM,CAAC,UAAU;IAKjB,oFAAoF;IACpF,MAAM,CAAC,KAAK,IAAI,OAAO,IAAI;CAM5B"}
|
package/lib/Http/index.js
CHANGED
|
@@ -15,12 +15,18 @@ class Http extends HttpHeader_1.HttpHeaders {
|
|
|
15
15
|
return url;
|
|
16
16
|
}
|
|
17
17
|
static get(url, params = {}) {
|
|
18
|
-
|
|
18
|
+
const response = this.axios.get(this.resolveParam(url), {
|
|
19
|
+
headers: this.headers,
|
|
20
|
+
});
|
|
21
|
+
this.reset();
|
|
22
|
+
return response;
|
|
19
23
|
}
|
|
20
24
|
static post(url, data = {}) {
|
|
21
|
-
|
|
25
|
+
const response = this.axios.post(this.resolveParam(url), data, {
|
|
22
26
|
headers: this.headers,
|
|
23
27
|
});
|
|
28
|
+
this.reset();
|
|
29
|
+
return response;
|
|
24
30
|
}
|
|
25
31
|
static withQueryParameters(params = {}) {
|
|
26
32
|
this.queryParams = params;
|
|
@@ -32,9 +38,11 @@ class Http extends HttpHeader_1.HttpHeaders {
|
|
|
32
38
|
return this;
|
|
33
39
|
}
|
|
34
40
|
static patch(url, data = {}) {
|
|
35
|
-
|
|
41
|
+
const response = this.axios.patch(this.resolveParam(url), data, {
|
|
36
42
|
headers: this.headers,
|
|
37
43
|
});
|
|
44
|
+
this.reset();
|
|
45
|
+
return response;
|
|
38
46
|
}
|
|
39
47
|
static withHeaders(headers) {
|
|
40
48
|
this.headers = headers;
|
|
@@ -44,12 +52,18 @@ class Http extends HttpHeader_1.HttpHeaders {
|
|
|
44
52
|
return this.withHeaders({ "Content-Type": this.HttpHeaders["form-data"] });
|
|
45
53
|
}
|
|
46
54
|
static put(url, data = {}) {
|
|
47
|
-
|
|
55
|
+
const response = this.axios.put(this.resolveParam(url), data, {
|
|
48
56
|
headers: this.headers,
|
|
49
57
|
});
|
|
58
|
+
this.reset();
|
|
59
|
+
return response;
|
|
50
60
|
}
|
|
51
61
|
static delete(url) {
|
|
52
|
-
|
|
62
|
+
const response = this.axios.delete(this.resolveParam(url), {
|
|
63
|
+
headers: this.headers,
|
|
64
|
+
});
|
|
65
|
+
this.reset();
|
|
66
|
+
return response;
|
|
53
67
|
}
|
|
54
68
|
static accept(content) {
|
|
55
69
|
this.headers = { Accept: content, ...this.headers };
|
|
@@ -59,6 +73,13 @@ class Http extends HttpHeader_1.HttpHeaders {
|
|
|
59
73
|
this.headers = { ...this.headers, Accept: this.HttpHeaders["json"] };
|
|
60
74
|
return this;
|
|
61
75
|
}
|
|
76
|
+
/** Clear fluent state so chained headers/query/body do not leak across requests. */
|
|
77
|
+
static reset() {
|
|
78
|
+
this.queryParams = {};
|
|
79
|
+
this.headers = {};
|
|
80
|
+
this.body = {};
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
62
83
|
}
|
|
63
84
|
exports.Http = Http;
|
|
64
85
|
//
|
package/lib/Interface/index.d.ts
CHANGED
|
@@ -28,9 +28,10 @@ export interface AppRequest extends Request {
|
|
|
28
28
|
*/
|
|
29
29
|
id: string;
|
|
30
30
|
/**
|
|
31
|
-
* JCC session
|
|
31
|
+
* JCC session bridge (same backing store as `express-session` + `connect-flash`).
|
|
32
|
+
* Set after session middleware when `req.session` exists.
|
|
32
33
|
*/
|
|
33
|
-
jccSession
|
|
34
|
+
jccSession?: Session;
|
|
34
35
|
/**
|
|
35
36
|
* Adds a validation method to the request object for validating incoming data.
|
|
36
37
|
*
|
|
@@ -129,6 +130,11 @@ export interface AppRequest extends Request {
|
|
|
129
130
|
hasFile(key: string): boolean;
|
|
130
131
|
isMethod(method: string): boolean;
|
|
131
132
|
fullUrl(): string;
|
|
133
|
+
/**
|
|
134
|
+
* Returns the CSRF token for the current session.
|
|
135
|
+
* Available when the csrf() middleware is active.
|
|
136
|
+
*/
|
|
137
|
+
csrfToken?: () => string;
|
|
132
138
|
}
|
|
133
139
|
export interface AppResponse extends Response {
|
|
134
140
|
redirectBack: () => any;
|
|
@@ -223,7 +229,9 @@ export interface CacheConfig {
|
|
|
223
229
|
};
|
|
224
230
|
}
|
|
225
231
|
export interface SessionConfig {
|
|
232
|
+
/** `file` | `database` (Knex/Jcc-eloquent) | `redis` */
|
|
226
233
|
driver: "file" | "database" | "redis";
|
|
234
|
+
/** Session lifetime in milliseconds (express-session cookie maxAge). */
|
|
227
235
|
lifetime: number;
|
|
228
236
|
cookie: {
|
|
229
237
|
name: string;
|
|
@@ -231,19 +239,25 @@ export interface SessionConfig {
|
|
|
231
239
|
secure: boolean;
|
|
232
240
|
sameSite: "strict" | "lax" | "none";
|
|
233
241
|
maxAge: number;
|
|
242
|
+
path?: string;
|
|
243
|
+
domain?: string;
|
|
234
244
|
};
|
|
235
245
|
files?: {
|
|
236
246
|
path: string;
|
|
237
247
|
};
|
|
238
248
|
database?: {
|
|
239
|
-
connection
|
|
249
|
+
/** Reserved for multi-connection setups; table name is primary. */
|
|
250
|
+
connection?: string;
|
|
240
251
|
table: string;
|
|
241
252
|
};
|
|
242
253
|
redis?: {
|
|
243
254
|
host: string;
|
|
244
255
|
port: number;
|
|
245
256
|
password?: string;
|
|
257
|
+
/** Redis DB index (default 0). */
|
|
246
258
|
database?: number;
|
|
259
|
+
/** Key prefix for session keys (default `session:`). */
|
|
260
|
+
prefix?: string;
|
|
247
261
|
};
|
|
248
262
|
}
|
|
249
263
|
export interface SessionData {
|