@arikajs/http 0.0.4 → 0.0.6

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.
Files changed (53) hide show
  1. package/README.md +33 -11
  2. package/dist/HttpKernel.d.ts +40 -0
  3. package/dist/HttpKernel.d.ts.map +1 -0
  4. package/dist/HttpKernel.js +75 -0
  5. package/dist/HttpKernel.js.map +1 -0
  6. package/dist/HttpServiceProvider.d.ts +13 -0
  7. package/dist/HttpServiceProvider.d.ts.map +1 -0
  8. package/dist/HttpServiceProvider.js +25 -0
  9. package/dist/HttpServiceProvider.js.map +1 -0
  10. package/dist/Middleware/BodyParserMiddleware.d.ts.map +1 -1
  11. package/dist/Middleware/BodyParserMiddleware.js +30 -2
  12. package/dist/Middleware/BodyParserMiddleware.js.map +1 -1
  13. package/dist/Middleware/SecurityHeaders.d.ts +12 -0
  14. package/dist/Middleware/SecurityHeaders.d.ts.map +1 -0
  15. package/dist/Middleware/SecurityHeaders.js +31 -0
  16. package/dist/Middleware/SecurityHeaders.js.map +1 -0
  17. package/dist/Middleware/ServeStaticMiddleware.d.ts +8 -0
  18. package/dist/Middleware/ServeStaticMiddleware.d.ts.map +1 -0
  19. package/dist/Middleware/ServeStaticMiddleware.js +35 -0
  20. package/dist/Middleware/ServeStaticMiddleware.js.map +1 -0
  21. package/dist/Middleware/Throttle.d.ts +17 -0
  22. package/dist/Middleware/Throttle.d.ts.map +1 -0
  23. package/dist/Middleware/Throttle.js +61 -0
  24. package/dist/Middleware/Throttle.js.map +1 -0
  25. package/dist/ObjectPool.d.ts +27 -0
  26. package/dist/ObjectPool.d.ts.map +1 -0
  27. package/dist/ObjectPool.js +50 -0
  28. package/dist/ObjectPool.js.map +1 -0
  29. package/dist/Pipeline.d.ts +23 -0
  30. package/dist/Pipeline.d.ts.map +1 -0
  31. package/dist/Pipeline.js +61 -0
  32. package/dist/Pipeline.js.map +1 -0
  33. package/dist/RawResponse.d.ts +9 -0
  34. package/dist/RawResponse.d.ts.map +1 -0
  35. package/dist/RawResponse.js +27 -0
  36. package/dist/RawResponse.js.map +1 -0
  37. package/dist/Request.d.ts +53 -3
  38. package/dist/Request.d.ts.map +1 -1
  39. package/dist/Request.js +170 -7
  40. package/dist/Request.js.map +1 -1
  41. package/dist/Response.d.ts +20 -3
  42. package/dist/Response.d.ts.map +1 -1
  43. package/dist/Response.js +48 -4
  44. package/dist/Response.js.map +1 -1
  45. package/dist/Router.d.ts +34 -0
  46. package/dist/Router.d.ts.map +1 -0
  47. package/dist/Router.js +150 -0
  48. package/dist/Router.js.map +1 -0
  49. package/dist/index.d.ts +8 -0
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +8 -0
  52. package/dist/index.js.map +1 -1
  53. package/package.json +13 -6
@@ -0,0 +1,34 @@
1
+ import { Request } from './Request';
2
+ import { Response } from './Response';
3
+ export type RouteAction = any;
4
+ export interface Route {
5
+ method: string;
6
+ path: string;
7
+ action: RouteAction;
8
+ middleware: any[];
9
+ }
10
+ export declare class Router {
11
+ protected routes: Route[];
12
+ protected groupStack: any[];
13
+ protected middlewareGroups: Record<string, any[]>;
14
+ group(attributes: any, callback: (router: Router) => void): void;
15
+ get(path: string, action: RouteAction): this;
16
+ post(path: string, action: RouteAction): this;
17
+ put(path: string, action: RouteAction): this;
18
+ delete(path: string, action: RouteAction): this;
19
+ patch(path: string, action: RouteAction): this;
20
+ options(path: string, action: RouteAction): this;
21
+ /**
22
+ * Add middleware to the last registered route.
23
+ */
24
+ middleware(middleware: any | any[]): this;
25
+ protected addRoute(method: string, path: string, action: RouteAction): this;
26
+ protected mergeGroupAttributes(): any;
27
+ protected prefixPath(prefix: string, path: string): string;
28
+ dispatch(request: Request, response: Response): Promise<Response>;
29
+ protected findRoute(request: Request): Route | null;
30
+ protected matchPath(routePath: string, requestPath: string, request: Request): boolean;
31
+ protected runRoute(route: Route, request: Request, response: Response): Promise<Response>;
32
+ private toResponse;
33
+ }
34
+ //# sourceMappingURL=Router.d.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CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI;IAc3E,SAAS,CAAC,oBAAoB,IAAI,GAAG;IAerC,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAQ7C,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAc9E,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK,GAAG,IAAI;IAanD,SAAS,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;cA2BtE,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAkB/F,OAAO,CAAC,UAAU;CAerB"}
package/dist/Router.js ADDED
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Router = void 0;
4
+ const Response_1 = require("./Response");
5
+ const Pipeline_1 = require("./Pipeline");
6
+ class Router {
7
+ constructor() {
8
+ this.routes = [];
9
+ this.groupStack = [];
10
+ this.middlewareGroups = {};
11
+ }
12
+ group(attributes, callback) {
13
+ this.groupStack.push(attributes);
14
+ callback(this);
15
+ this.groupStack.pop();
16
+ }
17
+ get(path, action) {
18
+ return this.addRoute('GET', path, action);
19
+ }
20
+ post(path, action) {
21
+ return this.addRoute('POST', path, action);
22
+ }
23
+ put(path, action) {
24
+ return this.addRoute('PUT', path, action);
25
+ }
26
+ delete(path, action) {
27
+ return this.addRoute('DELETE', path, action);
28
+ }
29
+ patch(path, action) {
30
+ return this.addRoute('PATCH', path, action);
31
+ }
32
+ options(path, action) {
33
+ return this.addRoute('OPTIONS', path, action);
34
+ }
35
+ /**
36
+ * Add middleware to the last registered route.
37
+ */
38
+ middleware(middleware) {
39
+ const lastRoute = this.routes[this.routes.length - 1];
40
+ if (lastRoute) {
41
+ if (Array.isArray(middleware)) {
42
+ lastRoute.middleware.push(...middleware);
43
+ }
44
+ else {
45
+ lastRoute.middleware.push(middleware);
46
+ }
47
+ }
48
+ return this;
49
+ }
50
+ addRoute(method, path, action) {
51
+ const attributes = this.mergeGroupAttributes();
52
+ const fullPath = this.prefixPath(attributes.prefix, path);
53
+ const middleware = [...(attributes.middleware || [])];
54
+ this.routes.push({
55
+ method,
56
+ path: fullPath,
57
+ action,
58
+ middleware
59
+ });
60
+ return this;
61
+ }
62
+ mergeGroupAttributes() {
63
+ const attributes = { prefix: '', middleware: [] };
64
+ for (const group of this.groupStack) {
65
+ if (group.prefix) {
66
+ attributes.prefix = this.prefixPath(attributes.prefix, group.prefix);
67
+ }
68
+ if (group.middleware) {
69
+ attributes.middleware = [...attributes.middleware, ...group.middleware];
70
+ }
71
+ }
72
+ return attributes;
73
+ }
74
+ prefixPath(prefix, path) {
75
+ const cleanedPrefix = prefix.replace(/\/+$/, '');
76
+ const cleanedPath = path.replace(/^\/+/, '');
77
+ if (!cleanedPrefix)
78
+ return cleanedPath.startsWith('/') ? cleanedPath : '/' + cleanedPath;
79
+ return cleanedPrefix + '/' + cleanedPath;
80
+ }
81
+ async dispatch(request, response) {
82
+ const route = this.findRoute(request);
83
+ if (!route) {
84
+ return response.status(404).json({ error: 'Route not found' });
85
+ }
86
+ const pipeline = new Pipeline_1.Pipeline(request.getApplication().getContainer());
87
+ return pipeline
88
+ .pipe(route.middleware)
89
+ .handle(request, (req) => this.runRoute(route, req, response), response);
90
+ }
91
+ findRoute(request) {
92
+ const path = request.path();
93
+ const method = request.method().toUpperCase();
94
+ for (const route of this.routes) {
95
+ if (route.method === method && this.matchPath(route.path, path, request)) {
96
+ return route;
97
+ }
98
+ }
99
+ return null;
100
+ }
101
+ matchPath(routePath, requestPath, request) {
102
+ // Simple parameter matching: /users/:id
103
+ const routeParts = routePath.split('/').filter(Boolean);
104
+ const requestParts = requestPath.split('/').filter(Boolean);
105
+ if (routeParts.length !== requestParts.length) {
106
+ return false;
107
+ }
108
+ const params = {};
109
+ for (let i = 0; i < routeParts.length; i++) {
110
+ if (routeParts[i].startsWith(':')) {
111
+ const paramName = routeParts[i].substring(1);
112
+ params[paramName] = requestParts[i];
113
+ continue;
114
+ }
115
+ if (routeParts[i] !== requestParts[i]) {
116
+ return false;
117
+ }
118
+ }
119
+ request.setParams(params);
120
+ return true;
121
+ }
122
+ async runRoute(route, request, response) {
123
+ const action = route.action;
124
+ if (typeof action === 'function') {
125
+ const result = await action(request, ...Object.values(request.params()));
126
+ return this.toResponse(result, response);
127
+ }
128
+ if (Array.isArray(action)) {
129
+ const [controllerClass, methodName] = action;
130
+ const controller = request.getApplication().make(controllerClass);
131
+ const result = await controller[methodName](request, ...Object.values(request.params()));
132
+ return this.toResponse(result, response);
133
+ }
134
+ throw new Error('Invalid route action');
135
+ }
136
+ toResponse(result, response) {
137
+ if (result instanceof Response_1.Response) {
138
+ return result;
139
+ }
140
+ if (typeof result === 'object') {
141
+ return response.json(result);
142
+ }
143
+ if (typeof result === 'string') {
144
+ return response.send(result);
145
+ }
146
+ return response;
147
+ }
148
+ }
149
+ exports.Router = Router;
150
+ //# sourceMappingURL=Router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Router.js","sourceRoot":"","sources":["../src/Router.ts"],"names":[],"mappings":";;;AACA,yCAAsC;AACtC,yCAAsC;AAWtC,MAAa,MAAM;IAAnB;QACc,WAAM,GAAY,EAAE,CAAC;QACrB,eAAU,GAAU,EAAE,CAAC;QACvB,qBAAgB,GAA0B,EAAE,CAAC;IA2K3D,CAAC;IAzKU,KAAK,CAAC,UAAe,EAAE,QAAkC;QAC5D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACjC,QAAQ,CAAC,IAAI,CAAC,C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CAAC;YACzE,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,MAAM,CAAC,eAAe,EAAE,UAAU,CAAC,GAAG,MAAM,CAAC;YAC7C,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAClE,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACzF,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC5C,CAAC;IAEO,UAAU,CAAC,MAAW,EAAE,QAAkB;QAC9C,IAAI,MAAM,YAAY,mBAAQ,EAAE,CAAC;YAC7B,OAAO,MAAM,CAAC;QAClB,CAAC;QAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;QAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AA9KD,wBA8KC"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,18 @@
1
1
  export * from './Request';
2
2
  export * from './Response';
3
+ export * from './HttpKernel';
4
+ export * from './Router';
5
+ export * from './Pipeline';
3
6
  export * from './Middleware';
4
7
  export * from './Middleware/BodyParserMiddleware';
5
8
  export * from './Middleware/CorsMiddleware';
6
9
  export * from './Middleware/TrimStrings';
7
10
  export * from './Middleware/ConvertEmptyStringsToNull';
11
+ export * from './Middleware/SecurityHeaders';
12
+ export * from './Middleware/Throttle';
8
13
  export * from './Exceptions/HttpException';
9
14
  export * from './Contracts/Application';
15
+ export * from './HttpServiceProvider';
16
+ export * from './Middleware/ServeStaticMiddleware';
17
+ export * from './RawResponse';
10
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wCAAwC,CAAC;AACvD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -16,11 +16,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Request"), exports);
18
18
  __exportStar(require("./Response"), exports);
19
+ __exportStar(require("./HttpKernel"), exports);
20
+ __exportStar(require("./Router"), exports);
21
+ __exportStar(require("./Pipeline"), exports);
19
22
  __exportStar(require("./Middleware"), exports);
20
23
  __exportStar(require("./Middleware/BodyParserMiddleware"), exports);
21
24
  __exportStar(require("./Middleware/CorsMiddleware"), exports);
22
25
  __exportStar(require("./Middleware/TrimStrings"), exports);
23
26
  __exportStar(require("./Middleware/ConvertEmptyStringsToNull"), exports);
27
+ __exportStar(require("./Middleware/SecurityHeaders"), exports);
28
+ __exportStar(require("./Middleware/Throttle"), exports);
24
29
  __exportStar(require("./Exceptions/HttpException"), exports);
25
30
  __exportStar(require("./Contracts/Application"), exports);
31
+ __exportStar(require("./HttpServiceProvider"), exports);
32
+ __exportStar(require("./Middleware/ServeStaticMiddleware"), exports);
33
+ __exportStar(require("./RawResponse"), exports);
26
34
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,6CAA2B;AAC3B,+CAA6B;AAC7B,oEAAkD;AAClD,8DAA4C;AAC5C,2DAAyC;AACzC,yEAAuD;AACvD,6DAA2C;AAC3C,0DAAwC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,6CAA2B;AAC3B,+CAA6B;AAC7B,2CAAyB;AACzB,6CAA2B;AAC3B,+CAA6B;AAC7B,oEAAkD;AAClD,8DAA4C;AAC5C,2DAAyC;AACzC,yEAAuD;AACvD,+DAA6C;AAC7C,wDAAsC;AACtC,6DAA2C;AAC3C,0DAAwC;AACxC,wDAAsC;AACtC,qEAAmD;AACnD,gDAA8B"}
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@arikajs/http",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Native HTTP layer for the ArikaJS framework.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/arikajs/http.git"
7
+ "url": "git+https://github.com/ArikaJs/arikajs.git",
8
+ "directory": "packages/http"
8
9
  },
9
10
  "bugs": {
10
- "url": "https://github.com/arikajs/http/issues"
11
+ "url": "https://github.com/ArikaJs/arikajs/issues"
11
12
  },
12
- "homepage": "https://github.com/arikajs/http#readme",
13
+ "homepage": "https://github.com/ArikaJs/arikajs/tree/main/packages/http#readme",
13
14
  "license": "MIT",
14
15
  "main": "dist/index.js",
15
16
  "types": "dist/index.d.ts",
@@ -18,7 +19,8 @@
18
19
  "clean": "rm -rf dist",
19
20
  "prepare": "echo skip",
20
21
  "test": "npx tsx --test tests/*.test.ts",
21
- "test:watch": "npx tsx --test --watch tests/*.test.ts"
22
+ "test:watch": "npx tsx --test --watch tests/*.test.ts",
23
+ "dev": "tsc -p tsconfig.json --watch"
22
24
  },
23
25
  "files": [
24
26
  "dist"
@@ -27,9 +29,14 @@
27
29
  "node": ">=20.0.0"
28
30
  },
29
31
  "dependencies": {
30
- "cookie": "^1.1.1"
32
+ "@arikajs/validation": "workspace:*",
33
+ "@types/serve-static": "^2.2.0",
34
+ "busboy": "^1.6.0",
35
+ "cookie": "^1.1.1",
36
+ "serve-static": "^2.2.1"
31
37
  },
32
38
  "devDependencies": {
39
+ "@types/busboy": "^1.5.4",
33
40
  "@types/cookie": "^0.6.0",
34
41
  "@types/node": "^20.11.24",
35
42
  "typescript": "^5.3.3"