jcc-express-mvc 1.8.5 → 1.8.7
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/Auth/Event.d.ts +2 -0
- package/Core/Auth/Event.d.ts.map +1 -0
- package/Core/Auth/Event.js +17 -0
- package/Core/Auth/index.d.ts +2 -0
- package/Core/Auth/index.d.ts.map +1 -0
- package/Core/Auth/index.js +2 -0
- package/Core/Console/Command.d.ts +2 -0
- package/Core/Console/Command.d.ts.map +1 -0
- package/Core/Console/Command.js +17 -0
- package/Core/Dependency.d.ts +1 -1
- package/Core/Dependency.js +1 -1
- package/Core/Gate.d.ts +2 -0
- package/Core/Gate.d.ts.map +1 -0
- package/Core/Gate.js +17 -0
- package/Core/Mail.d.ts +5 -0
- package/Core/Mail.d.ts.map +1 -1
- package/Core/Mail.js +5 -0
- package/Core/Schedule.d.ts +2 -0
- package/Core/Schedule.d.ts.map +1 -0
- package/Core/Schedule.js +17 -0
- package/Exception/index.d.ts +1 -1
- package/Exception/index.d.ts.map +1 -1
- package/Exception/index.js +1 -1
- package/__tests__/ApplicationBuilder.test.d.ts +2 -0
- package/__tests__/ApplicationBuilder.test.d.ts.map +1 -0
- package/__tests__/ApplicationBuilder.test.js +41 -0
- package/__tests__/Container.test.d.ts +2 -0
- package/__tests__/Container.test.d.ts.map +1 -0
- package/__tests__/Container.test.js +71 -0
- package/__tests__/ValidationException.test.d.ts +2 -0
- package/__tests__/ValidationException.test.d.ts.map +1 -0
- package/__tests__/ValidationException.test.js +24 -0
- package/lib/Application/ApplicationBuilder.d.ts +1 -1
- package/lib/Application/ApplicationBuilder.d.ts.map +1 -1
- package/lib/Application/ApplicationBuilder.js +16 -10
- package/lib/Auth/AuthMiddleware.js +2 -2
- package/lib/Auth/Event/Registered.d.ts +5 -0
- package/lib/Auth/Event/Registered.d.ts.map +1 -0
- package/lib/Auth/Event/Registered.js +11 -0
- package/lib/Auth/Listener/SendEmail.d.ts +5 -0
- package/lib/Auth/Listener/SendEmail.d.ts.map +1 -0
- package/lib/Auth/Listener/SendEmail.js +29 -0
- package/lib/Auth/index.js +3 -3
- 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 +25 -0
- package/lib/Command-Line/NodeArtisanCommand.d.ts.map +1 -1
- package/lib/Command-Line/NodeArtisanCommand.js +2 -0
- package/lib/Command-Line/files/FeatureTest.d.ts +7 -0
- package/lib/Command-Line/files/FeatureTest.d.ts.map +1 -0
- package/lib/Command-Line/files/FeatureTest.js +31 -0
- package/lib/{Dependancy → Dependency}/Route.d.ts.map +1 -1
- package/lib/Dependency/Route.js +27 -0
- package/lib/{Dependancy → Dependency}/index.d.ts.map +1 -1
- package/lib/{Dependancy → Dependency}/index.js +0 -22
- package/lib/Error/AppErrorHandler.d.ts.map +1 -1
- package/lib/Error/AppErrorHandler.js +4 -0
- package/lib/Error/DisplayErrorCode.d.ts +1 -1
- package/lib/Error/DisplayErrorCode.d.ts.map +1 -1
- package/lib/Error/DisplayErrorCode.js +2 -2
- package/lib/Error/{ErrorHightLight.d.ts → ErrorHighlight.d.ts} +1 -1
- package/lib/Error/ErrorHighlight.d.ts.map +1 -0
- package/lib/Error/ValidationException-v2/index.d.ts.map +1 -1
- package/lib/Error/ValidationException-v2/index.js +3 -2
- package/lib/Event/Event.d.ts.map +1 -1
- package/lib/Event/Event.js +14 -12
- package/lib/Global/helpers.js +2 -1
- package/lib/Inertia/index.js +1 -1
- package/lib/Interface/index.d.ts +1 -3
- package/lib/Interface/index.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Builder.d.ts +1 -1
- package/lib/Jcc-eloquent/lib/Builder.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Builder.js +17 -3
- package/lib/Jcc-eloquent/lib/Relations/EagerLoading.d.ts +16 -1
- package/lib/Jcc-eloquent/lib/Relations/EagerLoading.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Relations/EagerLoading.js +111 -15
- package/lib/Mail/Attachment.d.ts +37 -0
- package/lib/Mail/Attachment.d.ts.map +1 -0
- package/lib/Mail/Attachment.js +116 -0
- package/lib/Mail/Content/index.d.ts +42 -0
- package/lib/Mail/Content/index.d.ts.map +1 -0
- package/lib/Mail/Content/index.js +46 -0
- package/lib/Mail/Drivers/Nodemailer.d.ts +13 -0
- package/lib/Mail/Drivers/Nodemailer.d.ts.map +1 -0
- package/lib/Mail/Drivers/Nodemailer.js +62 -0
- package/lib/Mail/Drivers/Resend.d.ts +14 -0
- package/lib/Mail/Drivers/Resend.d.ts.map +1 -0
- package/lib/Mail/Drivers/Resend.js +97 -0
- package/lib/Mail/Envelope.d.ts +24 -0
- package/lib/Mail/Envelope.d.ts.map +1 -0
- package/lib/Mail/Envelope.js +37 -0
- package/lib/Mail/Mailable.d.ts +54 -0
- package/lib/Mail/Mailable.d.ts.map +1 -0
- package/lib/Mail/Mailable.js +62 -0
- package/lib/Mail/Manager.d.ts +15 -0
- package/lib/Mail/Manager.d.ts.map +1 -0
- package/lib/Mail/Manager.js +53 -0
- package/lib/Mail/index.d.ts +44 -16
- package/lib/Mail/index.d.ts.map +1 -1
- package/lib/Mail/index.js +57 -46
- package/lib/Mail/interface/Mailer.d.ts +5 -2
- package/lib/Mail/interface/Mailer.d.ts.map +1 -1
- package/lib/Mail/interface/MailerDriver.d.ts +13 -0
- package/lib/Mail/interface/MailerDriver.d.ts.map +1 -0
- package/lib/Mail/interface/MailerDriver.js +2 -0
- package/lib/Providers/AuthServiceProvider.d.ts +7 -0
- package/lib/Providers/AuthServiceProvider.d.ts.map +1 -0
- package/lib/Providers/AuthServiceProvider.js +20 -0
- package/lib/Providers/EventServiceProvider.d.ts +1 -1
- package/lib/Providers/EventServiceProvider.d.ts.map +1 -1
- package/lib/Providers/RouteServiceProvider.d.ts +1 -1
- package/lib/Providers/RouteServiceProvider.d.ts.map +1 -1
- package/lib/Providers/ServiceProvider.d.ts.map +1 -1
- package/lib/Providers/ServiceProvider.js +0 -4
- package/lib/Providers/SocketServiceProvider.d.ts +1 -1
- package/lib/Providers/SocketServiceProvider.d.ts.map +1 -1
- package/lib/Request/FormRequest.d.ts +0 -2
- package/lib/Request/FormRequest.d.ts.map +1 -1
- package/lib/Request/FormRequest.js +4 -9
- package/lib/Response/index.js +1 -1
- package/lib/Storage/index.d.ts +5 -0
- package/lib/Storage/index.d.ts.map +1 -1
- package/lib/Storage/index.js +12 -0
- package/package.json +1 -1
- package/lib/Dependancy/Route.js +0 -36
- package/lib/Error/ErrorHightLight.d.ts.map +0 -1
- package/lib/Error/ValidationException.d.ts +0 -6
- package/lib/Error/ValidationException.d.ts.map +0 -1
- package/lib/Error/ValidationException.js +0 -12
- /package/lib/{Dependancy → Dependency}/Route.d.ts +0 -0
- /package/lib/{Dependancy → Dependency}/index.d.ts +0 -0
- /package/lib/Error/{ErrorHightLight.js → ErrorHighlight.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Event.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/Core/Auth/Event.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("../../lib/Auth/Event/Registered"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/Core/Auth/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/Core/Console/Command.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("../../lib/Console/Command"), exports);
|
package/Core/Dependency.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "../lib/
|
|
1
|
+
export * from "../lib/Dependency";
|
|
2
2
|
//# sourceMappingURL=Dependency.d.ts.map
|
package/Core/Dependency.js
CHANGED
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("../lib/
|
|
17
|
+
__exportStar(require("../lib/Dependency"), exports);
|
package/Core/Gate.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Gate.d.ts","sourceRoot":"","sources":["../../jcc-express-mvc/Core/Gate.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
package/Core/Gate.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("../lib/Authorization/index"), exports);
|
package/Core/Mail.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export * from "../lib/Mail/index";
|
|
2
|
+
export * from "../lib/Mail/Manager";
|
|
2
3
|
export * from "../lib/Mail/interface/Mailer";
|
|
4
|
+
export * from "../lib/Mail/Content";
|
|
5
|
+
export * from "../lib/Mail/Mailable";
|
|
6
|
+
export * from "../lib/Mail/Envelope";
|
|
7
|
+
export * from "../lib/Mail/Attachment";
|
|
3
8
|
//# sourceMappingURL=Mail.d.ts.map
|
package/Core/Mail.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mail.d.ts","sourceRoot":"","sources":["../../jcc-express-mvc/Core/Mail.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"Mail.d.ts","sourceRoot":"","sources":["../../jcc-express-mvc/Core/Mail.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC"}
|
package/Core/Mail.js
CHANGED
|
@@ -15,4 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("../lib/Mail/index"), exports);
|
|
18
|
+
__exportStar(require("../lib/Mail/Manager"), exports);
|
|
18
19
|
__exportStar(require("../lib/Mail/interface/Mailer"), exports);
|
|
20
|
+
__exportStar(require("../lib/Mail/Content"), exports);
|
|
21
|
+
__exportStar(require("../lib/Mail/Mailable"), exports);
|
|
22
|
+
__exportStar(require("../lib/Mail/Envelope"), exports);
|
|
23
|
+
__exportStar(require("../lib/Mail/Attachment"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Schedule.d.ts","sourceRoot":"","sources":["../../jcc-express-mvc/Core/Schedule.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
package/Core/Schedule.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("../lib/Schedule"), exports);
|
package/Exception/index.d.ts
CHANGED
package/Exception/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../jcc-express-mvc/Exception/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../jcc-express-mvc/Exception/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC"}
|
package/Exception/index.js
CHANGED
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("../lib/Error/ValidationException"), exports);
|
|
17
|
+
__exportStar(require("../lib/Error/ValidationException-v2"), exports);
|
|
18
18
|
__exportStar(require("../lib/Error/AuthorizationException"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplicationBuilder.test.d.ts","sourceRoot":"","sources":["../../jcc-express-mvc/__tests__/ApplicationBuilder.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const Application_1 = require("../lib/Application/Application");
|
|
5
|
+
const ApplicationBuilder_1 = require("../lib/Application/ApplicationBuilder");
|
|
6
|
+
(0, vitest_1.describe)("ApplicationBuilder", () => {
|
|
7
|
+
let app;
|
|
8
|
+
(0, vitest_1.beforeEach)(() => {
|
|
9
|
+
app = Application_1.Application.getInstance();
|
|
10
|
+
});
|
|
11
|
+
(0, vitest_1.it)("withConfig merges config without queue when queue is missing", () => {
|
|
12
|
+
const config = { custom: "value" };
|
|
13
|
+
const builder = new ApplicationBuilder_1.ApplicationBuilder(app);
|
|
14
|
+
(0, vitest_1.expect)(() => builder.withConfig(config)).not.toThrow();
|
|
15
|
+
(0, vitest_1.expect)(app.config).toMatchObject({ custom: "value" });
|
|
16
|
+
(0, vitest_1.expect)(app.has("Queue")).toBe(false);
|
|
17
|
+
});
|
|
18
|
+
(0, vitest_1.it)("withConfig registers Queue when queue config is present", () => {
|
|
19
|
+
const config = {
|
|
20
|
+
queue: {
|
|
21
|
+
default: "memory",
|
|
22
|
+
connections: {
|
|
23
|
+
memory: { driver: "memory", queue: "default" },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const builder = new ApplicationBuilder_1.ApplicationBuilder(app);
|
|
28
|
+
builder.withConfig(config);
|
|
29
|
+
(0, vitest_1.expect)(app.has("Queue")).toBe(true);
|
|
30
|
+
const queue = app.resolve("Queue");
|
|
31
|
+
(0, vitest_1.expect)(queue).toBeDefined();
|
|
32
|
+
});
|
|
33
|
+
(0, vitest_1.it)("withRouting maps route config with rootPath", () => {
|
|
34
|
+
const builder = new ApplicationBuilder_1.ApplicationBuilder(app);
|
|
35
|
+
const routes = [{ name: "route/api", prefix: "/api" }];
|
|
36
|
+
builder.withRouting(routes);
|
|
37
|
+
(0, vitest_1.expect)(app.configRoutes).toHaveLength(1);
|
|
38
|
+
(0, vitest_1.expect)(app.configRoutes[0].name).toContain("route/api");
|
|
39
|
+
(0, vitest_1.expect)(app.configRoutes[0].prefix).toBe("/api");
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Container.test.d.ts","sourceRoot":"","sources":["../../jcc-express-mvc/__tests__/Container.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const Application_1 = require("../lib/Application/Application");
|
|
5
|
+
/**
|
|
6
|
+
* Tests Container behavior via Application (extends ExpressApplication extends Container).
|
|
7
|
+
*/
|
|
8
|
+
(0, vitest_1.describe)("Container", () => {
|
|
9
|
+
let container;
|
|
10
|
+
(0, vitest_1.beforeEach)(() => {
|
|
11
|
+
container = Application_1.Application.getInstance();
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.it)("binds and resolves a value via factory", () => {
|
|
14
|
+
container.bind("Foo", () => "bar");
|
|
15
|
+
(0, vitest_1.expect)(container.resolve("Foo")).toBe("bar");
|
|
16
|
+
});
|
|
17
|
+
(0, vitest_1.it)("binds a class and resolves instance", () => {
|
|
18
|
+
class Service {
|
|
19
|
+
}
|
|
20
|
+
container.bind("Service", Service, true);
|
|
21
|
+
const a = container.resolve("Service");
|
|
22
|
+
const b = container.resolve("Service");
|
|
23
|
+
(0, vitest_1.expect)(a).toBeInstanceOf(Service);
|
|
24
|
+
(0, vitest_1.expect)(a).toBe(b); // shared
|
|
25
|
+
});
|
|
26
|
+
(0, vitest_1.it)("singleton returns same instance", () => {
|
|
27
|
+
class Singleton {
|
|
28
|
+
}
|
|
29
|
+
container.singleton("Singleton", Singleton);
|
|
30
|
+
const a = container.resolve("Singleton");
|
|
31
|
+
const b = container.resolve("Singleton");
|
|
32
|
+
(0, vitest_1.expect)(a).toBe(b);
|
|
33
|
+
});
|
|
34
|
+
(0, vitest_1.it)("instance sets concrete instance", () => {
|
|
35
|
+
const obj = { id: 1 };
|
|
36
|
+
container.instance("Obj", obj);
|
|
37
|
+
(0, vitest_1.expect)(container.resolve("Obj")).toBe(obj);
|
|
38
|
+
});
|
|
39
|
+
(0, vitest_1.it)("alias resolves to original binding", () => {
|
|
40
|
+
container.bind("Original", () => "value");
|
|
41
|
+
container.alias("Original", "Alias");
|
|
42
|
+
(0, vitest_1.expect)(container.resolve("Alias")).toBe("value");
|
|
43
|
+
});
|
|
44
|
+
(0, vitest_1.it)("has returns true for registered bindings", () => {
|
|
45
|
+
container.bind("X", "y");
|
|
46
|
+
(0, vitest_1.expect)(container.has("X")).toBe(true);
|
|
47
|
+
(0, vitest_1.expect)(container.has("Unknown")).toBe(false);
|
|
48
|
+
});
|
|
49
|
+
(0, vitest_1.it)("forget removes instance", () => {
|
|
50
|
+
class Temp {
|
|
51
|
+
}
|
|
52
|
+
container.singleton("Temp", Temp);
|
|
53
|
+
const a = container.resolve("Temp");
|
|
54
|
+
container.forget("Temp");
|
|
55
|
+
const b = container.resolve("Temp");
|
|
56
|
+
(0, vitest_1.expect)(a).not.toBe(b);
|
|
57
|
+
});
|
|
58
|
+
(0, vitest_1.it)("make instantiates class with auto-binding", () => {
|
|
59
|
+
class MyService {
|
|
60
|
+
constructor() {
|
|
61
|
+
this.name = "test";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const instance = container.make(MyService);
|
|
65
|
+
(0, vitest_1.expect)(instance).toBeInstanceOf(MyService);
|
|
66
|
+
(0, vitest_1.expect)(instance?.name).toBe("test");
|
|
67
|
+
});
|
|
68
|
+
(0, vitest_1.it)("resolve throws for unregistered binding", () => {
|
|
69
|
+
(0, vitest_1.expect)(() => container.resolve("NonExistent")).toThrow(/No binding registered/);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationException.test.d.ts","sourceRoot":"","sources":["../../jcc-express-mvc/__tests__/ValidationException.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const ValidationException_v2_1 = require("../lib/Error/ValidationException-v2");
|
|
5
|
+
(0, vitest_1.describe)("ValidationException", () => {
|
|
6
|
+
(0, vitest_1.it)("creates exception with errors", () => {
|
|
7
|
+
const errors = { email: ["Invalid email"], name: ["Required"] };
|
|
8
|
+
const ex = new ValidationException_v2_1.ValidationException(errors);
|
|
9
|
+
(0, vitest_1.expect)(ex.errors).toEqual(errors);
|
|
10
|
+
(0, vitest_1.expect)(ex).toBeInstanceOf(Error);
|
|
11
|
+
(0, vitest_1.expect)(ex).toBeInstanceOf(ValidationException_v2_1.ValidationException);
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.it)("flattens message to first error per field", () => {
|
|
14
|
+
const errors = { email: ["Invalid", "Too short"], name: ["Required"] };
|
|
15
|
+
const ex = new ValidationException_v2_1.ValidationException(errors);
|
|
16
|
+
(0, vitest_1.expect)(ex.message).toEqual({ email: "Invalid", name: "Required" });
|
|
17
|
+
});
|
|
18
|
+
(0, vitest_1.it)("accepts custom messages", () => {
|
|
19
|
+
const errors = { field: ["validation.failed"] };
|
|
20
|
+
const customMessages = { "field.validation.failed": "Custom message" };
|
|
21
|
+
const ex = new ValidationException_v2_1.ValidationException(errors, customMessages);
|
|
22
|
+
(0, vitest_1.expect)(ex.errors).toEqual(errors);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationBuilder.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Application/ApplicationBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,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;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAQ3C,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;IActC,WAAW,CAAC,WAAW,EAAE,WAAW,EAAE;IAOtC,aAAa,CAClB,SAAS,EAAE,KAAK,CAAC,KAAK,GAAG,EAAE,WAAW,KAAK,eAAe,CAAC;IAgB7D,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,gBAAgB;IAIjB,WAAW;IAKX,cAAc;IAWd,MAAM;CAKd"}
|
|
@@ -5,6 +5,7 @@ const Middleware_1 = require("../Middleware");
|
|
|
5
5
|
const NodeArtisanCommand_1 = require("../Command-Line/NodeArtisanCommand");
|
|
6
6
|
const helpers_1 = require("../Global/helpers");
|
|
7
7
|
const Queue_1 = require("../Queue");
|
|
8
|
+
const AuthServiceProvider_1 = require("../Providers/AuthServiceProvider");
|
|
8
9
|
class ApplicationBuilder {
|
|
9
10
|
constructor(app) {
|
|
10
11
|
this.app = app;
|
|
@@ -15,13 +16,13 @@ class ApplicationBuilder {
|
|
|
15
16
|
}
|
|
16
17
|
withConfig(config) {
|
|
17
18
|
this.app.config = { ...this.app.config, ...config };
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
if (config.queue?.default && config.queue?.connections) {
|
|
20
|
+
this.app.singleton("Queue", () => {
|
|
21
|
+
const defaultConnection = config.queue.default;
|
|
22
|
+
const queueConfig = config.queue.connections[defaultConnection];
|
|
23
|
+
return new Queue_1.Queue(queueConfig ?? config.queue.connections.memory ?? { driver: "memory", queue: "default" });
|
|
24
|
+
});
|
|
25
|
+
}
|
|
25
26
|
return this;
|
|
26
27
|
}
|
|
27
28
|
withRouting(routeConfig) {
|
|
@@ -31,9 +32,14 @@ class ApplicationBuilder {
|
|
|
31
32
|
return this;
|
|
32
33
|
}
|
|
33
34
|
withProviders(providers) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
// Register AuthServiceProvider first when present (so auth events are set up before other providers)
|
|
36
|
+
const ordered = providers.includes(AuthServiceProvider_1.AuthServiceProvider) &&
|
|
37
|
+
providers[0] !== AuthServiceProvider_1.AuthServiceProvider
|
|
38
|
+
? [AuthServiceProvider_1.AuthServiceProvider, ...providers.filter((P) => P !== AuthServiceProvider_1.AuthServiceProvider)]
|
|
39
|
+
: providers;
|
|
40
|
+
ordered.forEach((Provider) => {
|
|
41
|
+
this.app.registerProviders(Provider);
|
|
42
|
+
});
|
|
37
43
|
return this;
|
|
38
44
|
}
|
|
39
45
|
withEvents() {
|
|
@@ -51,8 +51,8 @@ class AuthMiddleware {
|
|
|
51
51
|
const token = req.cookies.auth_token;
|
|
52
52
|
if (token) {
|
|
53
53
|
if (!req.get("Referer")) {
|
|
54
|
-
if (req.
|
|
55
|
-
return res.redirect(303, req.
|
|
54
|
+
if (req.previousUrls[0] == req.url) {
|
|
55
|
+
return res.redirect(303, req.previousUrls[1]);
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
58
|
res.clearCookie("auth_token");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Registered.d.ts","sourceRoot":"","sources":["../../../../jcc-express-mvc/lib/Auth/Event/Registered.ts"],"names":[],"mappings":"AAGA,qBAAa,UAAU;IACF,IAAI,EAAE,GAAG;gBAAT,IAAI,EAAE,GAAG;CAG7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SendEmail.d.ts","sourceRoot":"","sources":["../../../../jcc-express-mvc/lib/Auth/Listener/SendEmail.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD,qBAAa,SAAS;IACd,MAAM,CAAC,KAAK,EAAE,UAAU;CAuB/B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SendEmail = void 0;
|
|
4
|
+
const Mail_1 = require("../../Mail");
|
|
5
|
+
const Content_1 = require("../../Mail/Content");
|
|
6
|
+
const Config_1 = require("../../Config/Config");
|
|
7
|
+
class SendEmail {
|
|
8
|
+
async handle(event) {
|
|
9
|
+
const email = event?.user?.email;
|
|
10
|
+
if (!email || typeof email !== "string" || !email.includes("@")) {
|
|
11
|
+
console.warn("[SendEmail] Skipping verification email: invalid or missing user email");
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const url = `${Config_1.config.get("APP_URL")}/verify-email/${encodeURIComponent(email)}`;
|
|
15
|
+
await Mail_1.Mail.to(email).send({
|
|
16
|
+
content: new Content_1.Content({
|
|
17
|
+
view: "views.email.verification",
|
|
18
|
+
with: {
|
|
19
|
+
user: event?.user,
|
|
20
|
+
url,
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
subject: "Email Verification",
|
|
24
|
+
message: "Click the link to verify your email",
|
|
25
|
+
sender: event?.user?.name,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.SendEmail = SendEmail;
|
package/lib/Auth/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.Authentication = void 0;
|
|
5
5
|
const util_1 = require("../util");
|
|
6
6
|
const Config_1 = require("../Config/Config");
|
|
7
|
-
const
|
|
7
|
+
const ValidationException_v2_1 = require("../Error/ValidationException-v2");
|
|
8
8
|
const Jcc_eloquent_1 = require("../Jcc-eloquent");
|
|
9
9
|
const { User } = (0, util_1.getModel)("User");
|
|
10
10
|
class Authentication {
|
|
@@ -94,9 +94,9 @@ Authentication.attempt = async (req, res, next, redirect = "/home") => {
|
|
|
94
94
|
try {
|
|
95
95
|
const { user, field } = await _a.getUser(req.body);
|
|
96
96
|
if (!user)
|
|
97
|
-
throw new
|
|
97
|
+
throw new ValidationException_v2_1.ValidationException({ [field]: ["Invalid credentials"] });
|
|
98
98
|
if (!(await (0, util_1.verifyHash)(req.body.password, user.password))) {
|
|
99
|
-
throw new
|
|
99
|
+
throw new ValidationException_v2_1.ValidationException({ [field]: ["Invalid credentials"] });
|
|
100
100
|
}
|
|
101
101
|
const tokens = _a.setTokens(res, user.id || user._id);
|
|
102
102
|
if (req.expectsJson() && !req.isInertia()) {
|
|
@@ -12,5 +12,6 @@ export declare class MakeCommand {
|
|
|
12
12
|
createObserver(name: string, model?: string): any;
|
|
13
13
|
createPolicy(name: string, model?: string): any;
|
|
14
14
|
createCommand(name: string, customSignature?: string): any;
|
|
15
|
+
createFeatureTest(name: string): any;
|
|
15
16
|
}
|
|
16
17
|
//# sourceMappingURL=MakeCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MakeCommand.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Command-Line/MakeCommand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MakeCommand.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Command-Line/MakeCommand.ts"],"names":[],"mappings":"AA6BA,qBAAa,WAAW;IACtB,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,GAAG;IAkChE,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,GAAG;IAkDnE,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG;IAoBnC,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG;IA0BvC,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,GAAG;IA4BlE,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;IA2B/B,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG;IA8B/B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IA8B3B,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,GAAG;IAmC1D,gBAAgB;IA+BhB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,GAAG;IAiCjD,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,GAAG;IAmC/C,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,GAAG;IAkC1D,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;CA8BrC"}
|
|
@@ -22,6 +22,7 @@ const jobClass_1 = require("./files/jobClass");
|
|
|
22
22
|
const Observer_1 = __importDefault(require("./files/Observer"));
|
|
23
23
|
const Policy_1 = __importDefault(require("./files/Policy"));
|
|
24
24
|
const Command_1 = __importDefault(require("./files/Command"));
|
|
25
|
+
const FeatureTest_1 = require("./files/FeatureTest");
|
|
25
26
|
const rootPath = app_root_path_1.default.path;
|
|
26
27
|
/** Convert PascalCase to kebab-case (e.g. SendEmails -> send:emails) */
|
|
27
28
|
const toSignature = (name) => name
|
|
@@ -343,5 +344,29 @@ class MakeCommand {
|
|
|
343
344
|
console.log(err.message);
|
|
344
345
|
}
|
|
345
346
|
}
|
|
347
|
+
createFeatureTest(name) {
|
|
348
|
+
try {
|
|
349
|
+
if (!name) {
|
|
350
|
+
console.log(colors_1.default.red("Please give a name for your test (e.g. UsersTest)"));
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const testName = name.endsWith("Test") ? name : name + "Test";
|
|
354
|
+
const testsPath = path_1.default.resolve(`${rootPath}/tests/Feature`);
|
|
355
|
+
if (!fs_1.default.existsSync(testsPath)) {
|
|
356
|
+
fs_1.default.mkdirSync(testsPath, { recursive: true });
|
|
357
|
+
}
|
|
358
|
+
const testFile = `${testsPath}/${testName}.test.ts`;
|
|
359
|
+
if (fs_1.default.existsSync(testFile)) {
|
|
360
|
+
console.log(colors_1.default.yellow(`${testName}.test.ts already exists`));
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
fs_1.default.writeFileSync(testFile, (0, FeatureTest_1.createFeatureTest)(testName));
|
|
364
|
+
return console.log(colors_1.default.green(`${testName} added successfully [${testFile}]`));
|
|
365
|
+
}
|
|
366
|
+
catch (err) {
|
|
367
|
+
console.log(colors_1.default.red(`${name} test not added`));
|
|
368
|
+
console.log(err.message);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
346
371
|
}
|
|
347
372
|
exports.MakeCommand = MakeCommand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeArtisanCommand.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Command-Line/NodeArtisanCommand.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmCpC,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAK1B;IACF,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,GAAG,CAA0B;IACrC,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,IAAI,CAAc;IAE1B,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,KAAK,EAAE,GAEb;IAED,OAAO,KAAK,IAAI,GAEf;IAED,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,KAAK,QAAQ,GAEnB;IACD,OAAO,CAAC,GAAG;;IAWX,0FAA0F;IAC1F,OAAO,CAAC,kBAAkB;IA0B1B,OAAO,CAAC,aAAa;IAOrB,wFAAwF;IACxF,OAAO,CAAC,SAAS;IAkBjB,OAAO,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"NodeArtisanCommand.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Command-Line/NodeArtisanCommand.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmCpC,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAK1B;IACF,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,GAAG,CAA0B;IACrC,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,IAAI,CAAc;IAE1B,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,KAAK,EAAE,GAEb;IAED,OAAO,KAAK,IAAI,GAEf;IAED,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,KAAK,QAAQ,GAEnB;IACD,OAAO,CAAC,GAAG;;IAWX,0FAA0F;IAC1F,OAAO,CAAC,kBAAkB;IA0B1B,OAAO,CAAC,aAAa;IAOrB,wFAAwF;IACxF,OAAO,CAAC,SAAS;IAkBjB,OAAO,CAAC,aAAa;IA+JrB,OAAO,CAAC,QAAQ;IAiIhB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;CA4BpD"}
|
|
@@ -153,6 +153,7 @@ class ConsoleKernel {
|
|
|
153
153
|
const signature = parseOption(secondArg, "signature");
|
|
154
154
|
this.make.createCommand(name, signature);
|
|
155
155
|
}));
|
|
156
|
+
this.defineCommand("make:test").action(this.runAction((name) => this.make.createFeatureTest(name)));
|
|
156
157
|
// ─── migrate / db ───────────────────────────────────────────────────
|
|
157
158
|
this.defineCommand("migrate").action(this.runAction(() => this.migrate.runMigration()));
|
|
158
159
|
this.defineCommand("migrate:fresh").action(this.runAction(() => this.migrate.fresh()));
|
|
@@ -218,6 +219,7 @@ class ConsoleKernel {
|
|
|
218
219
|
console.log(line("make:observer <name> [model=]", "Create a new model observer class"));
|
|
219
220
|
console.log(line("make:policy <name> [model=]", "Create an authorization policy class"));
|
|
220
221
|
console.log(line("make:command <name> [signature=]", "Create a new console command class"));
|
|
222
|
+
console.log(line("make:test <name>", "Create a new feature test (e.g. UsersTest)"));
|
|
221
223
|
console.log(line("make:queue-table", "Create migration for queue tables\n"));
|
|
222
224
|
console.log(section("🗄️ Database Commands:"));
|
|
223
225
|
console.log(line("migrate", "Run all pending database migrations"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FeatureTest.d.ts","sourceRoot":"","sources":["../../../../jcc-express-mvc/lib/Command-Line/files/FeatureTest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,MAqBhD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFeatureTest = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Template for a feature test file.
|
|
6
|
+
* @param name - Test class name (e.g. UsersTest, PostsTest)
|
|
7
|
+
* @returns string - File content
|
|
8
|
+
*/
|
|
9
|
+
const createFeatureTest = (name) => {
|
|
10
|
+
return `import { describe, it, beforeEach, afterEach } from "vitest";
|
|
11
|
+
import { TestCase } from "../TestCase";
|
|
12
|
+
|
|
13
|
+
describe("${name.replace(/Test$/, "")}", () => {
|
|
14
|
+
const test = new (class extends TestCase {})();
|
|
15
|
+
|
|
16
|
+
beforeEach(async () => {
|
|
17
|
+
await test.setUp();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(async () => {
|
|
21
|
+
await test.tearDown();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("can make a request", async () => {
|
|
25
|
+
const response = await test.get("/api");
|
|
26
|
+
response.assertStatus(200);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
`;
|
|
30
|
+
};
|
|
31
|
+
exports.createFeatureTest = createFeatureTest;
|