arikajs 0.0.1
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/LICENSE +21 -0
- package/README.md +432 -0
- package/dist/Application.d.ts +32 -0
- package/dist/Application.d.ts.map +1 -0
- package/dist/Application.js +122 -0
- package/dist/Application.js.map +1 -0
- package/dist/Contracts/Application.d.ts +17 -0
- package/dist/Contracts/Application.d.ts.map +1 -0
- package/dist/Contracts/Application.js +3 -0
- package/dist/Contracts/Application.js.map +1 -0
- package/dist/createApp.d.ts +6 -0
- package/dist/createApp.d.ts.map +1 -0
- package/dist/createApp.js +11 -0
- package/dist/createApp.js.map +1 -0
- package/dist/http/Handler.d.ts +36 -0
- package/dist/http/Handler.d.ts.map +1 -0
- package/dist/http/Handler.js +95 -0
- package/dist/http/Handler.js.map +1 -0
- package/dist/http/Kernel.d.ts +33 -0
- package/dist/http/Kernel.d.ts.map +1 -0
- package/dist/http/Kernel.js +84 -0
- package/dist/http/Kernel.js.map +1 -0
- package/dist/http/Middleware/RequestLoggingMiddleware.d.ts +4 -0
- package/dist/http/Middleware/RequestLoggingMiddleware.d.ts.map +1 -0
- package/dist/http/Middleware/RequestLoggingMiddleware.js +17 -0
- package/dist/http/Middleware/RequestLoggingMiddleware.js.map +1 -0
- package/dist/http/Middleware/ValidateRequestMiddleware.d.ts +13 -0
- package/dist/http/Middleware/ValidateRequestMiddleware.d.ts.map +1 -0
- package/dist/http/Middleware/ValidateRequestMiddleware.js +34 -0
- package/dist/http/Middleware/ValidateRequestMiddleware.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/AuthServiceProvider.d.ts +12 -0
- package/dist/providers/AuthServiceProvider.d.ts.map +1 -0
- package/dist/providers/AuthServiceProvider.js +28 -0
- package/dist/providers/AuthServiceProvider.js.map +1 -0
- package/dist/providers/DatabaseServiceProvider.d.ts +12 -0
- package/dist/providers/DatabaseServiceProvider.d.ts.map +1 -0
- package/dist/providers/DatabaseServiceProvider.js +39 -0
- package/dist/providers/DatabaseServiceProvider.js.map +1 -0
- package/dist/providers/FrameworkServiceProvider.d.ts +6 -0
- package/dist/providers/FrameworkServiceProvider.d.ts.map +1 -0
- package/dist/providers/FrameworkServiceProvider.js +28 -0
- package/dist/providers/FrameworkServiceProvider.js.map +1 -0
- package/dist/providers/HttpServiceProvider.d.ts +13 -0
- package/dist/providers/HttpServiceProvider.d.ts.map +1 -0
- package/dist/providers/HttpServiceProvider.js +34 -0
- package/dist/providers/HttpServiceProvider.js.map +1 -0
- package/dist/providers/LoggingServiceProvider.d.ts +6 -0
- package/dist/providers/LoggingServiceProvider.d.ts.map +1 -0
- package/dist/providers/LoggingServiceProvider.js +19 -0
- package/dist/providers/LoggingServiceProvider.js.map +1 -0
- package/dist/providers/ValidationServiceProvider.d.ts +8 -0
- package/dist/providers/ValidationServiceProvider.d.ts.map +1 -0
- package/dist/providers/ValidationServiceProvider.js +26 -0
- package/dist/providers/ValidationServiceProvider.js.map +1 -0
- package/package.json +39 -0
- package/src/Application.ts +101 -0
- package/src/Contracts/Application.ts +18 -0
- package/src/createApp.ts +9 -0
- package/src/http/Handler.ts +101 -0
- package/src/http/Kernel.ts +92 -0
- package/src/http/Middleware/RequestLoggingMiddleware.ts +17 -0
- package/src/http/Middleware/ValidateRequestMiddleware.ts +35 -0
- package/src/index.ts +33 -0
- package/src/providers/AuthServiceProvider.ts +28 -0
- package/src/providers/DatabaseServiceProvider.ts +40 -0
- package/src/providers/FrameworkServiceProvider.ts +26 -0
- package/src/providers/HttpServiceProvider.ts +35 -0
- package/src/providers/LoggingServiceProvider.ts +17 -0
- package/src/providers/ValidationServiceProvider.ts +24 -0
- package/tests/Framework.test.ts +120 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Request, Response } from '@arikajs/http';
|
|
2
|
+
export declare class Handler {
|
|
3
|
+
/**
|
|
4
|
+
* A list of the exception types that should not be reported.
|
|
5
|
+
*/
|
|
6
|
+
protected dontReport: any[];
|
|
7
|
+
/**
|
|
8
|
+
* Custom renderers for specific exception types.
|
|
9
|
+
*/
|
|
10
|
+
protected renderers: Map<any, (request: Request, error: any, response: Response) => Response>;
|
|
11
|
+
/**
|
|
12
|
+
* Report or log an exception.
|
|
13
|
+
*/
|
|
14
|
+
report(error: any): void;
|
|
15
|
+
/**
|
|
16
|
+
* Render an exception into an HTTP response.
|
|
17
|
+
*/
|
|
18
|
+
render(request: Request, error: any, response: Response): Response;
|
|
19
|
+
/**
|
|
20
|
+
* Determine if the exception should be reported.
|
|
21
|
+
*/
|
|
22
|
+
protected shouldReport(error: any): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Determine if the stack trace should be displayed.
|
|
25
|
+
*/
|
|
26
|
+
protected shouldDisplayStackTrace(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Register a custom renderer for an exception type.
|
|
29
|
+
*/
|
|
30
|
+
renderable(type: any, renderer: (request: Request, error: any, response: Response) => Response): this;
|
|
31
|
+
/**
|
|
32
|
+
* Add an exception type to the dontReport list.
|
|
33
|
+
*/
|
|
34
|
+
ignore(type: any): this;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=Handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Handler.d.ts","sourceRoot":"","sources":["../../src/http/Handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAiB,MAAM,eAAe,CAAC;AAGjE,qBAAa,OAAO;IAChB;;OAEG;IACH,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE,CAAM;IAEjC;;OAEG;IACH,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAa;IAE1G;;OAEG;IACI,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAU/B;;OAEG;IACI,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,GAAG,QAAQ;IAsCzE;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO;IAI3C;;OAEG;IACH,SAAS,CAAC,uBAAuB,IAAI,OAAO;IAI5C;;OAEG;IACI,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,KAAK,QAAQ,GAAG,IAAI;IAK5G;;OAEG;IACI,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;CAMjC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Handler = void 0;
|
|
4
|
+
const http_1 = require("@arikajs/http");
|
|
5
|
+
const logging_1 = require("@arikajs/logging");
|
|
6
|
+
class Handler {
|
|
7
|
+
constructor() {
|
|
8
|
+
/**
|
|
9
|
+
* A list of the exception types that should not be reported.
|
|
10
|
+
*/
|
|
11
|
+
this.dontReport = [];
|
|
12
|
+
/**
|
|
13
|
+
* Custom renderers for specific exception types.
|
|
14
|
+
*/
|
|
15
|
+
this.renderers = new Map();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Report or log an exception.
|
|
19
|
+
*/
|
|
20
|
+
report(error) {
|
|
21
|
+
if (this.shouldReport(error)) {
|
|
22
|
+
logging_1.Log.error(error.message || 'Error', {
|
|
23
|
+
stack: error.stack,
|
|
24
|
+
name: error.name || 'Error',
|
|
25
|
+
originalError: error.originalError
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Render an exception into an HTTP response.
|
|
31
|
+
*/
|
|
32
|
+
render(request, error, response) {
|
|
33
|
+
// 1. Check if the error has a custom renderer
|
|
34
|
+
for (const [type, renderer] of this.renderers.entries()) {
|
|
35
|
+
if (error instanceof type) {
|
|
36
|
+
return renderer(request, error, response);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// 2. Check if the error is "renderable" (has a render method)
|
|
40
|
+
if (typeof error.render === 'function') {
|
|
41
|
+
return error.render(request, response);
|
|
42
|
+
}
|
|
43
|
+
// 3. Handle HttpException specifically
|
|
44
|
+
if (error instanceof http_1.HttpException) {
|
|
45
|
+
return response.status(error.getStatusCode()).json({
|
|
46
|
+
error: true,
|
|
47
|
+
message: error.message,
|
|
48
|
+
...(this.shouldDisplayStackTrace() ? { trace: error.stack } : {})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// 4. Default error handling
|
|
52
|
+
const status = error.statusCode || error.status || 500;
|
|
53
|
+
const message = status === 500 && !this.shouldDisplayStackTrace()
|
|
54
|
+
? 'Internal Server Error'
|
|
55
|
+
: error.message || 'Unknown Error';
|
|
56
|
+
return response.status(status).json({
|
|
57
|
+
error: true,
|
|
58
|
+
message: message,
|
|
59
|
+
...(this.shouldDisplayStackTrace() ? {
|
|
60
|
+
name: error.name,
|
|
61
|
+
trace: error.stack
|
|
62
|
+
} : {})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Determine if the exception should be reported.
|
|
67
|
+
*/
|
|
68
|
+
shouldReport(error) {
|
|
69
|
+
return !this.dontReport.some(type => error instanceof type);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Determine if the stack trace should be displayed.
|
|
73
|
+
*/
|
|
74
|
+
shouldDisplayStackTrace() {
|
|
75
|
+
return process.env.NODE_ENV === 'development' || process.env.APP_DEBUG === 'true';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Register a custom renderer for an exception type.
|
|
79
|
+
*/
|
|
80
|
+
renderable(type, renderer) {
|
|
81
|
+
this.renderers.set(type, renderer);
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Add an exception type to the dontReport list.
|
|
86
|
+
*/
|
|
87
|
+
ignore(type) {
|
|
88
|
+
if (!this.dontReport.includes(type)) {
|
|
89
|
+
this.dontReport.push(type);
|
|
90
|
+
}
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.Handler = Handler;
|
|
95
|
+
//# sourceMappingURL=Handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Handler.js","sourceRoot":"","sources":["../../src/http/Handler.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Application } from '../Contracts/Application';
|
|
2
|
+
import { Request, Response } from '@arikajs/http';
|
|
3
|
+
import { Handler } from './Handler';
|
|
4
|
+
export declare class Kernel {
|
|
5
|
+
protected app: Application;
|
|
6
|
+
/**
|
|
7
|
+
* The application's global HTTP middleware stack.
|
|
8
|
+
*/
|
|
9
|
+
protected middleware: any[];
|
|
10
|
+
/**
|
|
11
|
+
* The application's route middleware groups.
|
|
12
|
+
*/
|
|
13
|
+
protected middlewareGroups: Record<string, any[]>;
|
|
14
|
+
/**
|
|
15
|
+
* The application's route middleware.
|
|
16
|
+
*/
|
|
17
|
+
protected routeMiddleware: Record<string, any>;
|
|
18
|
+
protected handler: Handler;
|
|
19
|
+
constructor(app: Application);
|
|
20
|
+
/**
|
|
21
|
+
* Handle an incoming HTTP request.
|
|
22
|
+
*/
|
|
23
|
+
handle(request: Request, response: Response): Promise<Response>;
|
|
24
|
+
/**
|
|
25
|
+
* Dispatch the request to the router.
|
|
26
|
+
*/
|
|
27
|
+
protected dispatchToRouter(request: Request, response: Response): Promise<Response>;
|
|
28
|
+
/**
|
|
29
|
+
* Send the response back to the client.
|
|
30
|
+
*/
|
|
31
|
+
terminate(request: Request, response: Response): void;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=Kernel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Kernel.d.ts","sourceRoot":"","sources":["../../src/http/Kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAyB,MAAM,eAAe,CAAC;AAKzE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,qBAAa,MAAM;IA2BH,SAAS,CAAC,GAAG,EAAE,WAAW;IA1BtC;;OAEG;IACH,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE,CAMzB;IAEF;;OAEG;IACH,SAAS,CAAC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAG/C;IAEF;;OAEG;IACH,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;IAEpD,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC;gBAEL,GAAG,EAAE,WAAW;IAQtC;;OAEG;IACU,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAgB5E;;OAEG;cACa,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAoBzF;;OAEG;IACI,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAG/D"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Kernel = void 0;
|
|
4
|
+
const http_1 = require("@arikajs/http");
|
|
5
|
+
const middleware_1 = require("@arikajs/middleware");
|
|
6
|
+
const RequestLoggingMiddleware_1 = require("./Middleware/RequestLoggingMiddleware");
|
|
7
|
+
const http_2 = require("@arikajs/http");
|
|
8
|
+
const Handler_1 = require("./Handler");
|
|
9
|
+
class Kernel {
|
|
10
|
+
constructor(app) {
|
|
11
|
+
this.app = app;
|
|
12
|
+
/**
|
|
13
|
+
* The application's global HTTP middleware stack.
|
|
14
|
+
*/
|
|
15
|
+
this.middleware = [
|
|
16
|
+
new http_2.CorsMiddleware(),
|
|
17
|
+
new RequestLoggingMiddleware_1.RequestLoggingMiddleware(),
|
|
18
|
+
new http_2.BodyParserMiddleware(),
|
|
19
|
+
new http_2.TrimStrings(),
|
|
20
|
+
new http_2.ConvertEmptyStringsToNull(),
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* The application's route middleware groups.
|
|
24
|
+
*/
|
|
25
|
+
this.middlewareGroups = {
|
|
26
|
+
web: [],
|
|
27
|
+
api: [],
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The application's route middleware.
|
|
31
|
+
*/
|
|
32
|
+
this.routeMiddleware = {};
|
|
33
|
+
try {
|
|
34
|
+
this.handler = this.app.make(Handler_1.Handler);
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
this.handler = new Handler_1.Handler();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Handle an incoming HTTP request.
|
|
42
|
+
*/
|
|
43
|
+
async handle(request, response) {
|
|
44
|
+
try {
|
|
45
|
+
const pipeline = new middleware_1.Pipeline(this.app.getContainer());
|
|
46
|
+
pipeline.setMiddlewareGroups(this.middlewareGroups);
|
|
47
|
+
pipeline.setAliases(this.routeMiddleware);
|
|
48
|
+
return await pipeline.pipe(this.middleware)
|
|
49
|
+
.handle(request, async (req) => {
|
|
50
|
+
return this.dispatchToRouter(req, response);
|
|
51
|
+
}, response);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
this.handler.report(error);
|
|
55
|
+
return this.handler.render(request, error, response);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Dispatch the request to the router.
|
|
60
|
+
*/
|
|
61
|
+
async dispatchToRouter(request, response) {
|
|
62
|
+
const router = this.app.getRouter();
|
|
63
|
+
// Ensure router's dispatcher has kernel's middleware configuration
|
|
64
|
+
if (router.setMiddlewareGroups) {
|
|
65
|
+
router.setMiddlewareGroups(this.middlewareGroups);
|
|
66
|
+
}
|
|
67
|
+
if (router.setRouteMiddleware) {
|
|
68
|
+
router.setRouteMiddleware(this.routeMiddleware);
|
|
69
|
+
}
|
|
70
|
+
const result = await router.dispatch(request, response);
|
|
71
|
+
if (result === null) {
|
|
72
|
+
throw new http_1.NotFoundHttpException(`Route not found: [${request.method()}] ${request.path()}`);
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Send the response back to the client.
|
|
78
|
+
*/
|
|
79
|
+
terminate(request, response) {
|
|
80
|
+
response.terminate();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.Kernel = Kernel;
|
|
84
|
+
//# sourceMappingURL=Kernel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Kernel.js","sourceRoot":"","sources":["../../src/http/Kernel.ts"],"names":[],"mappings":";;;AACA,wCAAyE;AACzE,oDAA+C;AAE/C,oFAAiF;AACjF,wCAA6G;AAC7G,uCAAoC;AAEpC,MAAa,MAAM;IA2Bf,YAAsB,GAAgB;QAAhB,QAAG,GAAH,GAAG,CAAa;QA1BtC;;WAEG;QACO,eAAU,GAAU;YAC1B,IAAI,qBAAc,EAAE;YACpB,IAAI,mDAAwB,EAAE;YAC9B,IAAI,2BAAoB,EAAE;YAC1B,IAAI,kBAAW,EAAE;YACjB,IAAI,gCAAyB,EAAE;SAClC,CAAC;QAEF;;WAEG;QACO,qBAAgB,GAA0B;YAChD,GAAG,EAAE,EAAE;YACP,GAAG,EAAE,EAAE;SACV,CAAC;QAEF;;WAEG;QACO,oBAAe,GAAwB,EAAE,CAAC;QAKhD,IAAI,CAAC;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAO,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;QACjC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAAC,OAAgB,EAAE,QAAkB;QACpD,IAAI,CAAC;YACD,MAAM,QAAQ,GAAG,IAAI,qBAAQ,CAAoB,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;YAC1E,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YACpD,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAE1C,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;iBACtC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,GAAY,EAAE,EAAE;gBACpC,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YAChD,CAAC,EAAE,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACzD,CAAC;IACL,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,gBAAgB,CAAC,OAAgB,EAAE,QAAkB;QACjE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QAEpC,mEAAmE;QACnE,IAAK,MAAc,CAAC,mBAAmB,EAAE,CAAC;YACrC,MAAc,CAAC,mBAAmB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC/D,CAAC;QACD,IAAK,MAAc,CAAC,kBAAkB,EAAE,CAAC;YACpC,MAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAExD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YAClB,MAAM,IAAI,4BAAqB,CAAC,qBAAqB,OAAO,CAAC,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAChG,CAAC;QAED,OAAO,MAAkB,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,OAAgB,EAAE,QAAkB;QACjD,QAAQ,CAAC,SAAS,EAAE,CAAC;IACzB,CAAC;CACJ;AAnFD,wBAmFC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequestLoggingMiddleware.d.ts","sourceRoot":"","sources":["../../../src/http/Middleware/RequestLoggingMiddleware.ts"],"names":[],"mappings":"AAGA,qBAAa,wBAAwB;IACpB,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;CAYxF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequestLoggingMiddleware = void 0;
|
|
4
|
+
const logging_1 = require("@arikajs/logging");
|
|
5
|
+
class RequestLoggingMiddleware {
|
|
6
|
+
async handle(request, next) {
|
|
7
|
+
const start = Date.now();
|
|
8
|
+
const method = request.method();
|
|
9
|
+
const url = request.path();
|
|
10
|
+
const response = await next(request);
|
|
11
|
+
const duration = Date.now() - start;
|
|
12
|
+
logging_1.Log.info(`${method} ${url} - ${duration}ms`);
|
|
13
|
+
return response;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.RequestLoggingMiddleware = RequestLoggingMiddleware;
|
|
17
|
+
//# sourceMappingURL=RequestLoggingMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequestLoggingMiddleware.js","sourceRoot":"","sources":["../../../src/http/Middleware/RequestLoggingMiddleware.ts"],"names":[],"mappings":";;;AACA,8CAAuC;AAEvC,MAAa,wBAAwB;IAC1B,KAAK,CAAC,MAAM,CAAC,OAAY,EAAE,IAAoC;QAClE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QAChC,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAE3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;QAErC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QACpC,aAAG,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,GAAG,MAAM,QAAQ,IAAI,CAAC,CAAC;QAE7C,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AAbD,4DAaC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Request, Response } from '@arikajs/http';
|
|
2
|
+
export declare class ValidateRequestMiddleware {
|
|
3
|
+
protected rules: Record<string, any>;
|
|
4
|
+
/**
|
|
5
|
+
* Set the validation rules.
|
|
6
|
+
*/
|
|
7
|
+
using(rules: Record<string, any>): this;
|
|
8
|
+
/**
|
|
9
|
+
* Handle the incoming request.
|
|
10
|
+
*/
|
|
11
|
+
handle(request: Request, next: (request: Request) => Promise<Response>, response: Response): Promise<Response>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=ValidateRequestMiddleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidateRequestMiddleware.d.ts","sourceRoot":"","sources":["../../../src/http/Middleware/ValidateRequestMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGlD,qBAAa,yBAAyB;IAClC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAM;IAE1C;;OAEG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAK9C;;OAEG;IACU,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;CAgB9H"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValidateRequestMiddleware = void 0;
|
|
4
|
+
const validation_1 = require("@arikajs/validation");
|
|
5
|
+
class ValidateRequestMiddleware {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.rules = {};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Set the validation rules.
|
|
11
|
+
*/
|
|
12
|
+
using(rules) {
|
|
13
|
+
this.rules = rules;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Handle the incoming request.
|
|
18
|
+
*/
|
|
19
|
+
async handle(request, next, response) {
|
|
20
|
+
if (Object.keys(this.rules).length === 0) {
|
|
21
|
+
return next(request);
|
|
22
|
+
}
|
|
23
|
+
const validator = new validation_1.Validator(request.all(), this.rules);
|
|
24
|
+
if (await validator.fails()) {
|
|
25
|
+
return response.status(422).json({
|
|
26
|
+
message: 'The given data was invalid.',
|
|
27
|
+
errors: validator.errors()
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return next(request);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.ValidateRequestMiddleware = ValidateRequestMiddleware;
|
|
34
|
+
//# sourceMappingURL=ValidateRequestMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidateRequestMiddleware.js","sourceRoot":"","sources":["../../../src/http/Middleware/ValidateRequestMiddleware.ts"],"names":[],"mappings":";;;AAEA,oDAAgD;AAEhD,MAAa,yBAAyB;IAAtC;QACc,UAAK,GAAwB,EAAE,CAAC;IA6B9C,CAAC;IA3BG;;OAEG;IACI,KAAK,CAAC,KAA0B;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAAC,OAAgB,EAAE,IAA6C,EAAE,QAAkB;QACnG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAE3D,IAAI,MAAM,SAAS,CAAC,KAAK,EAAE,EAAE,CAAC;YAC1B,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBAC7B,OAAO,EAAE,6BAA6B;gBACtC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE;aAC7B,CAAC,CAAC;QACP,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;CACJ;AA9BD,8DA8BC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './Application';
|
|
2
|
+
export * from './createApp';
|
|
3
|
+
export { ServiceProvider } from '@arikajs/foundation';
|
|
4
|
+
export { Container } from '@arikajs/foundation';
|
|
5
|
+
export { Repository as Config } from '@arikajs/foundation';
|
|
6
|
+
export { Request, Response } from '@arikajs/http';
|
|
7
|
+
export { Kernel } from './http/Kernel';
|
|
8
|
+
export { Route } from '@arikajs/router';
|
|
9
|
+
export { Pipeline, MiddlewareHandler } from '@arikajs/middleware';
|
|
10
|
+
export { Model, Database as DB, Schema } from '@arikajs/database';
|
|
11
|
+
export { Cache } from '@arikajs/cache';
|
|
12
|
+
export { Queue, BaseJob } from '@arikajs/queue';
|
|
13
|
+
export { Encrypter } from '@arikajs/encryption';
|
|
14
|
+
export { Log } from '@arikajs/logging';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAG5B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAGxC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
exports.Log = exports.Encrypter = exports.BaseJob = exports.Queue = exports.Cache = exports.Schema = exports.DB = exports.Model = exports.Pipeline = exports.Route = exports.Kernel = exports.Response = exports.Request = exports.Config = exports.Container = exports.ServiceProvider = void 0;
|
|
18
|
+
__exportStar(require("./Application"), exports);
|
|
19
|
+
__exportStar(require("./createApp"), exports);
|
|
20
|
+
// Re-export common foundation items for convenience
|
|
21
|
+
var foundation_1 = require("@arikajs/foundation");
|
|
22
|
+
Object.defineProperty(exports, "ServiceProvider", { enumerable: true, get: function () { return foundation_1.ServiceProvider; } });
|
|
23
|
+
var foundation_2 = require("@arikajs/foundation");
|
|
24
|
+
Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return foundation_2.Container; } });
|
|
25
|
+
var foundation_3 = require("@arikajs/foundation");
|
|
26
|
+
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return foundation_3.Repository; } });
|
|
27
|
+
// Re-export HTTP items
|
|
28
|
+
var http_1 = require("@arikajs/http");
|
|
29
|
+
Object.defineProperty(exports, "Request", { enumerable: true, get: function () { return http_1.Request; } });
|
|
30
|
+
Object.defineProperty(exports, "Response", { enumerable: true, get: function () { return http_1.Response; } });
|
|
31
|
+
var Kernel_1 = require("./http/Kernel");
|
|
32
|
+
Object.defineProperty(exports, "Kernel", { enumerable: true, get: function () { return Kernel_1.Kernel; } });
|
|
33
|
+
// Re-export Routing items
|
|
34
|
+
var router_1 = require("@arikajs/router");
|
|
35
|
+
Object.defineProperty(exports, "Route", { enumerable: true, get: function () { return router_1.Route; } });
|
|
36
|
+
// Re-export Middleware items
|
|
37
|
+
var middleware_1 = require("@arikajs/middleware");
|
|
38
|
+
Object.defineProperty(exports, "Pipeline", { enumerable: true, get: function () { return middleware_1.Pipeline; } });
|
|
39
|
+
// Re-export Database items
|
|
40
|
+
var database_1 = require("@arikajs/database");
|
|
41
|
+
Object.defineProperty(exports, "Model", { enumerable: true, get: function () { return database_1.Model; } });
|
|
42
|
+
Object.defineProperty(exports, "DB", { enumerable: true, get: function () { return database_1.Database; } });
|
|
43
|
+
Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return database_1.Schema; } });
|
|
44
|
+
// Re-export Cache items
|
|
45
|
+
var cache_1 = require("@arikajs/cache");
|
|
46
|
+
Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { return cache_1.Cache; } });
|
|
47
|
+
// Re-export Queue items
|
|
48
|
+
var queue_1 = require("@arikajs/queue");
|
|
49
|
+
Object.defineProperty(exports, "Queue", { enumerable: true, get: function () { return queue_1.Queue; } });
|
|
50
|
+
Object.defineProperty(exports, "BaseJob", { enumerable: true, get: function () { return queue_1.BaseJob; } });
|
|
51
|
+
// Re-export Encryption items
|
|
52
|
+
var encryption_1 = require("@arikajs/encryption");
|
|
53
|
+
Object.defineProperty(exports, "Encrypter", { enumerable: true, get: function () { return encryption_1.Encrypter; } });
|
|
54
|
+
// Re-export Logging items
|
|
55
|
+
var logging_1 = require("@arikajs/logging");
|
|
56
|
+
Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return logging_1.Log; } });
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,gDAA8B;AAC9B,8CAA4B;AAE5B,oDAAoD;AACpD,kDAAsD;AAA7C,6GAAA,eAAe,OAAA;AACxB,kDAAgD;AAAvC,uGAAA,SAAS,OAAA;AAClB,kDAA2D;AAAlD,oGAAA,UAAU,OAAU;AAE7B,uBAAuB;AACvB,sCAAkD;AAAzC,+FAAA,OAAO,OAAA;AAAE,gGAAA,QAAQ,OAAA;AAC1B,wCAAuC;AAA9B,gGAAA,MAAM,OAAA;AAEf,0BAA0B;AAC1B,0CAAwC;AAA/B,+FAAA,KAAK,OAAA;AAEd,6BAA6B;AAC7B,kDAAkE;AAAzD,sGAAA,QAAQ,OAAA;AAEjB,2BAA2B;AAC3B,8CAAkE;AAAzD,iGAAA,KAAK,OAAA;AAAE,8FAAA,QAAQ,OAAM;AAAE,kGAAA,MAAM,OAAA;AAEtC,wBAAwB;AACxB,wCAAuC;AAA9B,8FAAA,KAAK,OAAA;AAEd,wBAAwB;AACxB,wCAAgD;AAAvC,8FAAA,KAAK,OAAA;AAAE,gGAAA,OAAO,OAAA;AAEvB,6BAA6B;AAC7B,kDAAgD;AAAvC,uGAAA,SAAS,OAAA;AAElB,0BAA0B;AAC1B,4CAAuC;AAA9B,8FAAA,GAAG,OAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ServiceProvider } from '@arikajs/foundation';
|
|
2
|
+
export declare class AuthServiceProvider extends ServiceProvider {
|
|
3
|
+
/**
|
|
4
|
+
* Register the authentication services.
|
|
5
|
+
*/
|
|
6
|
+
register(): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Boot the authentication services.
|
|
9
|
+
*/
|
|
10
|
+
boot(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=AuthServiceProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthServiceProvider.d.ts","sourceRoot":"","sources":["../../src/providers/AuthServiceProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,qBAAa,mBAAoB,SAAQ,eAAe;IACpD;;OAEG;IACU,QAAQ;IAarB;;OAEG;IACU,IAAI;CAGpB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthServiceProvider = void 0;
|
|
4
|
+
const foundation_1 = require("@arikajs/foundation");
|
|
5
|
+
const auth_1 = require("@arikajs/auth");
|
|
6
|
+
class AuthServiceProvider extends foundation_1.ServiceProvider {
|
|
7
|
+
/**
|
|
8
|
+
* Register the authentication services.
|
|
9
|
+
*/
|
|
10
|
+
async register() {
|
|
11
|
+
this.app.singleton('auth', () => {
|
|
12
|
+
return new auth_1.AuthManager(this.app.config().get('auth', {}));
|
|
13
|
+
});
|
|
14
|
+
this.app.bind(auth_1.AuthManager, () => this.app.resolve('auth'));
|
|
15
|
+
// Register the authentication middleware
|
|
16
|
+
this.app.bind(auth_1.Authenticate, () => {
|
|
17
|
+
return new auth_1.Authenticate(this.app.resolve(auth_1.AuthManager));
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Boot the authentication services.
|
|
22
|
+
*/
|
|
23
|
+
async boot() {
|
|
24
|
+
// Here we could register default guards etc.
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.AuthServiceProvider = AuthServiceProvider;
|
|
28
|
+
//# sourceMappingURL=AuthServiceProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthServiceProvider.js","sourceRoot":"","sources":["../../src/providers/AuthServiceProvider.ts"],"names":[],"mappings":";;;AACA,oDAAsD;AACtD,wCAA0D;AAE1D,MAAa,mBAAoB,SAAQ,4BAAe;IACpD;;OAEG;IACI,KAAK,CAAC,QAAQ;QACjB,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;YAC5B,OAAO,IAAI,kBAAW,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAW,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QAE3D,yCAAyC;QACzC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAY,EAAE,GAAG,EAAE;YAC7B,OAAO,IAAI,mBAAY,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAW,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI;QACb,6CAA6C;IACjD,CAAC;CACJ;AAvBD,kDAuBC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ServiceProvider } from '@arikajs/foundation';
|
|
2
|
+
export declare class DatabaseServiceProvider extends ServiceProvider {
|
|
3
|
+
/**
|
|
4
|
+
* Register the database services.
|
|
5
|
+
*/
|
|
6
|
+
register(): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Boot the database services.
|
|
9
|
+
*/
|
|
10
|
+
boot(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=DatabaseServiceProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseServiceProvider.d.ts","sourceRoot":"","sources":["../../src/providers/DatabaseServiceProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,qBAAa,uBAAwB,SAAQ,eAAe;IACxD;;OAEG;IACU,QAAQ;IAwBrB;;OAEG;IACU,IAAI;CAIpB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseServiceProvider = void 0;
|
|
4
|
+
const foundation_1 = require("@arikajs/foundation");
|
|
5
|
+
const database_1 = require("@arikajs/database");
|
|
6
|
+
class DatabaseServiceProvider extends foundation_1.ServiceProvider {
|
|
7
|
+
/**
|
|
8
|
+
* Register the database services.
|
|
9
|
+
*/
|
|
10
|
+
async register() {
|
|
11
|
+
this.app.singleton('db', () => {
|
|
12
|
+
const config = this.app.config().get('database');
|
|
13
|
+
if (!config) {
|
|
14
|
+
// If no config provided, we'll use a default memory sqlite for convenience
|
|
15
|
+
// though usually this should throw in production.
|
|
16
|
+
return new database_1.DatabaseManager({
|
|
17
|
+
default: 'sqlite',
|
|
18
|
+
connections: {
|
|
19
|
+
sqlite: {
|
|
20
|
+
driver: 'sqlite',
|
|
21
|
+
database: ':memory:'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return new database_1.DatabaseManager(config);
|
|
27
|
+
});
|
|
28
|
+
this.app.bind(database_1.DatabaseManager, () => this.app.resolve('db'));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Boot the database services.
|
|
32
|
+
*/
|
|
33
|
+
async boot() {
|
|
34
|
+
// Initialize the static Database facade
|
|
35
|
+
database_1.Database.setManager(this.app.resolve(database_1.DatabaseManager));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.DatabaseServiceProvider = DatabaseServiceProvider;
|
|
39
|
+
//# sourceMappingURL=DatabaseServiceProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseServiceProvider.js","sourceRoot":"","sources":["../../src/providers/DatabaseServiceProvider.ts"],"names":[],"mappings":";;;AACA,oDAAsD;AACtD,gDAA8D;AAE9D,MAAa,uBAAwB,SAAQ,4BAAe;IACxD;;OAEG;IACI,KAAK,CAAC,QAAQ;QACjB,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE;YAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YAEjD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACV,2EAA2E;gBAC3E,kDAAkD;gBAClD,OAAO,IAAI,0BAAe,CAAC;oBACvB,OAAO,EAAE,QAAQ;oBACjB,WAAW,EAAE;wBACT,MAAM,EAAE;4BACJ,MAAM,EAAE,QAAQ;4BAChB,QAAQ,EAAE,UAAU;yBACvB;qBACJ;iBACG,CAAC,CAAC;YACd,CAAC;YAED,OAAO,IAAI,0BAAe,CAAC,MAAa,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,0BAAe,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAI;QACb,wCAAwC;QACxC,mBAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,0BAAe,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ;AAnCD,0DAmCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FrameworkServiceProvider.d.ts","sourceRoot":"","sources":["../../src/providers/FrameworkServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAOtD,qBAAa,wBAAyB,SAAQ,eAAe;IAC5C,QAAQ;IAcR,IAAI;CAGpB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FrameworkServiceProvider = void 0;
|
|
4
|
+
const foundation_1 = require("@arikajs/foundation");
|
|
5
|
+
const encryption_1 = require("@arikajs/encryption");
|
|
6
|
+
const LoggingServiceProvider_1 = require("./LoggingServiceProvider");
|
|
7
|
+
const AuthServiceProvider_1 = require("./AuthServiceProvider");
|
|
8
|
+
const ValidationServiceProvider_1 = require("./ValidationServiceProvider");
|
|
9
|
+
const DatabaseServiceProvider_1 = require("./DatabaseServiceProvider");
|
|
10
|
+
class FrameworkServiceProvider extends foundation_1.ServiceProvider {
|
|
11
|
+
async register() {
|
|
12
|
+
// Register Core Services
|
|
13
|
+
await this.app.register(LoggingServiceProvider_1.LoggingServiceProvider);
|
|
14
|
+
await this.app.register(AuthServiceProvider_1.AuthServiceProvider);
|
|
15
|
+
await this.app.register(ValidationServiceProvider_1.ValidationServiceProvider);
|
|
16
|
+
await this.app.register(DatabaseServiceProvider_1.DatabaseServiceProvider);
|
|
17
|
+
// Register framework specific services
|
|
18
|
+
this.app.singleton('encrypter', () => {
|
|
19
|
+
const key = this.app.config().get('app.key');
|
|
20
|
+
return new encryption_1.Encrypter(key);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async boot() {
|
|
24
|
+
// Boot framework specific services
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.FrameworkServiceProvider = FrameworkServiceProvider;
|
|
28
|
+
//# sourceMappingURL=FrameworkServiceProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FrameworkServiceProvider.js","sourceRoot":"","sources":["../../src/providers/FrameworkServiceProvider.ts"],"names":[],"mappings":";;;AAAA,oDAAsD;AACtD,oDAAgD;AAChD,qEAAkE;AAClE,+DAA4D;AAC5D,2EAAwE;AACxE,uEAAoE;AAEpE,MAAa,wBAAyB,SAAQ,4BAAe;IAClD,KAAK,CAAC,QAAQ;QACjB,yBAAyB;QACzB,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,+CAAsB,CAAC,CAAC;QAChD,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,yCAAmB,CAAC,CAAC;QAC7C,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,qDAAyB,CAAC,CAAC;QACnD,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,iDAAuB,CAAC,CAAC;QAEjD,uCAAuC;QACvC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,GAAG,EAAE;YACjC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC7C,OAAO,IAAI,sBAAS,CAAC,GAAa,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,KAAK,CAAC,IAAI;QACb,mCAAmC;IACvC,CAAC;CACJ;AAlBD,4DAkBC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ServiceProvider } from '@arikajs/foundation';
|
|
2
|
+
import { Application } from '../Contracts/Application';
|
|
3
|
+
export declare class HttpServiceProvider extends ServiceProvider<Application> {
|
|
4
|
+
/**
|
|
5
|
+
* Register the service provider.
|
|
6
|
+
*/
|
|
7
|
+
register(): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Boot the service provider.
|
|
10
|
+
*/
|
|
11
|
+
boot(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=HttpServiceProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpServiceProvider.d.ts","sourceRoot":"","sources":["../../src/providers/HttpServiceProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAItD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,qBAAa,mBAAoB,SAAQ,eAAe,CAAC,WAAW,CAAC;IACjE;;OAEG;IACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBtC;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAGrC"}
|