alado 2.0.0 → 2.1.0

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.
@@ -0,0 +1,3 @@
1
+ github: databikers
2
+ patreon: databikers
3
+ custom: ['https://dir.floss.fund/view/@databikers.com']
@@ -0,0 +1,31 @@
1
+ name: Bug Report
2
+ description: Report a reproducible bug or unexpected behavior
3
+ labels: [bug]
4
+ body:
5
+ - type: input
6
+ id: title
7
+ attributes:
8
+ label: Summary
9
+ placeholder: 'Short description of the bug'
10
+ validations:
11
+ required: true
12
+
13
+ - type: textarea
14
+ id: steps
15
+ attributes:
16
+ label: Steps to Reproduce
17
+ description: 'What did you do? What did you expect?'
18
+ placeholder: |
19
+ 1. Run npm start
20
+ 2. Observe crash
21
+ validations:
22
+ required: true
23
+
24
+ - type: textarea
25
+ id: logs
26
+ attributes:
27
+ label: Logs / Error Output
28
+ render: shell
29
+ placeholder: Paste any error messages here
30
+ validations:
31
+ required: false
@@ -0,0 +1,5 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: Ask a question
4
+ url: https://github.com/databikers/alado/discussions
5
+ about: Ask usage questions or request help
@@ -0,0 +1,27 @@
1
+ name: Feature Request
2
+ description: Propose a new feature for Alado
3
+ labels: [enhancement]
4
+ body:
5
+ - type: input
6
+ id: title
7
+ attributes:
8
+ label: Feature Title
9
+ placeholder: 'e.g. add some feature'
10
+ validations:
11
+ required: true
12
+
13
+ - type: textarea
14
+ id: use-case
15
+ attributes:
16
+ label: Use Case / Motivation
17
+ placeholder: Why would this be helpful?
18
+ validations:
19
+ required: true
20
+
21
+ - type: textarea
22
+ id: implementation
23
+ attributes:
24
+ label: Optional implementation ideas
25
+ placeholder: How could it be done?
26
+ validations:
27
+ required: false
@@ -0,0 +1,52 @@
1
+ name: Question
2
+ description: Ask a general question about usage, implementation, or behavior.
3
+ title: "[Question]: "
4
+ labels: [question]
5
+ assignees: []
6
+
7
+ body:
8
+ - type: markdown
9
+ attributes:
10
+ value: |
11
+ ## Need Help?
12
+ If you have a general question about the project, please fill out the details below.
13
+
14
+ - type: input
15
+ id: context
16
+ attributes:
17
+ label: What are you trying to do?
18
+ description: Explain what you're working on or trying to achieve.
19
+ placeholder: e.g. I’m trying to add user using a CLI tool...
20
+ validations:
21
+ required: true
22
+
23
+ - type: textarea
24
+ id: what-happened
25
+ attributes:
26
+ label: What is confusing or unclear?
27
+ description: Describe what you don't understand or what needs more explanation.
28
+ placeholder: I expected it to work like this... but instead...
29
+ validations:
30
+ required: true
31
+
32
+ - type: dropdown
33
+ id: environment
34
+ attributes:
35
+ label: Environment
36
+ description: Where are you running this?
37
+ options:
38
+ - Local (Linux)
39
+ - Docker
40
+ - Other
41
+ multiple: false
42
+ validations:
43
+ required: false
44
+
45
+ - type: textarea
46
+ id: additional
47
+ attributes:
48
+ label: Anything else?
49
+ description: Add any other context or screenshots that might help.
50
+ placeholder: Logs, screenshots, error messages, etc.
51
+ validations:
52
+ required: false
package/README.md CHANGED
@@ -6,8 +6,8 @@ it provides out-of-the-box such fully-functioning features as routing, CORS, aut
6
6
  parsing query and path parameters, and the request body, file uploading, request authentication, etc.
7
7
 
8
8
  # Documentation for version 2.0.0 and above:
9
- Version 2.0.0 comes with decorators that simplify the project structure and minimize the amount of code you need to write.
10
9
 
10
+ Version 2.0.0 comes with decorators that simplify the project structure and minimize the amount of code you need to write.
11
11
 
12
12
  There is an example of the API creating with Alado (version >= 2.0.0):
13
13
  [https://github.com/databikers/alado-decorators-api-example](https://github.com/databikers/alado-decorators-api-example)
@@ -26,6 +26,7 @@ head(path: string, options: HttpDecoratorOptions = {})
26
26
  ```
27
27
 
28
28
  #### Arguments
29
+
29
30
  - **path**: Route string (e.g., `/users/:id`).
30
31
  - **options**: `HttpDecoratorOptions` object, may include:
31
32
  - `appId`: Identifier of the application instance.
@@ -43,6 +44,7 @@ defineRequest(request: Partial<Record<keyof [Request](#request), AnyClass>>)
43
44
  ```
44
45
 
45
46
  #### Arguments
47
+
46
48
  - **request**: A partial mapping of keys from [Request](#request) to your DTO classes.
47
49
  - Keys can include:
48
50
  - `headers`, `query`, `path`, `body`: each a record of property definitions.
@@ -78,6 +80,7 @@ defineResponse(response: [Response](#response)<any>)
78
80
  ```
79
81
 
80
82
  #### Arguments
83
+
81
84
  - **response**: Response schema definition, including:
82
85
  - `title`: Short descriptive title.
83
86
  - `description`: Explanation of the response.
@@ -96,6 +99,7 @@ interface Response<T> {
96
99
  body?: T;
97
100
  }
98
101
  ```
102
+
99
103
  ---
100
104
 
101
105
  ### `withAuth` decorator
@@ -105,6 +109,7 @@ withAuth(requestAuthentication: [RequestAuthentication](#requestauthentication))
105
109
  ```
106
110
 
107
111
  #### Arguments
112
+
108
113
  - **requestAuthentication**: Defines authentication requirements, including:
109
114
  - `inputProperty`: Field name in request used for auth input.
110
115
  - `outputProperty`: Field name in request to store auth result.
@@ -126,7 +131,6 @@ interface RequestAuthentication {
126
131
  }
127
132
  ```
128
133
 
129
-
130
134
  ```typescript
131
135
  import { RequestAuthentication } from 'alado';
132
136
  import { DataStore } from '@data-store';
@@ -143,7 +147,6 @@ export const bearerAuth: RequestAuthentication = {
143
147
  message: 'Unauthorized',
144
148
  },
145
149
  };
146
-
147
150
  ```
148
151
 
149
152
  #### `AladoServerError`
@@ -154,11 +157,11 @@ type AladoServerError = {
154
157
  message: string;
155
158
  };
156
159
  ```
160
+
157
161
  ---
158
162
 
159
163
  Example of controller:
160
164
 
161
-
162
165
  ```ts
163
166
  export class UserController {
164
167
  @post('/user', { tags: ['User'] })
@@ -178,7 +181,7 @@ export class UserController {
178
181
  body: user,
179
182
  };
180
183
  }
181
-
184
+
182
185
  @patch('/user/:id', { tags: ['User'] })
183
186
  @withAuth(bearerAuth)
184
187
  @defineResponse({
@@ -247,7 +250,6 @@ export class UserController {
247
250
  body: {},
248
251
  };
249
252
  }
250
-
251
253
  }
252
254
  ```
253
255
 
@@ -262,6 +264,7 @@ fileUploadProperty(filePropertyDefinition: [FilePropertyDefinition](#filepropert
262
264
  ```
263
265
 
264
266
  #### Arguments
267
+
265
268
  - **filePropertyDefinition**: Object describing file upload rules, including:
266
269
  - `mimetypes`: Array of allowed MIME types.
267
270
  - `maxSize`: Maximum file size (bytes).
@@ -290,6 +293,7 @@ documentProperty(propertyDocumentation: [PropertyDocumentation](#propertydocumen
290
293
  ```
291
294
 
292
295
  #### Arguments
296
+
293
297
  - **propertyDocumentation**: Documentation metadata for a property, including:
294
298
  - `schema`: JSON Schema–like definition (`type`, `format`, validation structure).
295
299
  - `description`: Human-readable explanation.
@@ -343,6 +347,14 @@ interface PropertyDefinitionSchema {
343
347
 
344
348
  ---
345
349
 
350
+ ### `transformProperty`
351
+
352
+ ```ts
353
+ transformProperty(propertyTransformer: (value:any) => any | Promise<any>)
354
+
355
+ ```
356
+
357
+
346
358
  ### `validateProperty`
347
359
 
348
360
  ```ts
@@ -350,6 +362,7 @@ validateProperty(propertyValidation: [PropertyValidation](#propertyvalidation))
350
362
  ```
351
363
 
352
364
  #### Arguments
365
+
353
366
  - **propertyValidation**: Validation rules, including:
354
367
  - `required`: Whether the property is mandatory.
355
368
  - `handler`: Function to validate the property value (sync or async).
@@ -366,6 +379,7 @@ interface PropertyValidation {
366
379
  ```
367
380
 
368
381
  ---
382
+
369
383
  DTOs examples:
370
384
 
371
385
  ```typescript
@@ -389,10 +403,8 @@ export class Id {
389
403
  })
390
404
  id: string = '7ef5ed25-53b1-432f-96ec-8e35d830eb9c';
391
405
  }
392
-
393
406
  ```
394
407
 
395
-
396
408
  ```typescript
397
409
  import { fileUploadProperty } from 'alado';
398
410
 
@@ -416,7 +428,6 @@ export class UserFilesDto {
416
428
  })
417
429
  avatar: string = '/path/to/image.png';
418
430
  }
419
-
420
431
  ```
421
432
 
422
433
  ```typescript
@@ -459,7 +470,6 @@ export class CredentialsDto {
459
470
  }
460
471
 
461
472
  export const credentialsDto = new CredentialsDto();
462
-
463
473
  ```
464
474
 
465
475
  ---
@@ -475,14 +485,14 @@ import { UserController } from '@user';
475
485
 
476
486
  export const app = initializeApplication({
477
487
  serverOptions: aladoServerOptions,
478
- controllers: [UserController]
488
+ controllers: [UserController],
479
489
  });
480
490
 
481
491
  app.start(() => console.log('Application has been successfully started'));
482
-
483
492
  ```
484
493
 
485
494
  #### Arguments
495
+
486
496
  - **initializeApplicationOptions**: Object containing:
487
497
  - **serverOptions** ([AladoServerOptions](#aladoserveroptions)): Configuration for starting the server (e.g., `appId`, port, logger).
488
498
  - **controllers**: Array of controller classes to initialize at startup.
@@ -515,8 +525,6 @@ interface AladoServerLogger {
515
525
  }
516
526
  ```
517
527
 
518
-
519
-
520
528
  There is an example of the API creating with Alado (version < 2.0.0):
521
529
 
522
530
  The basis of use is a combination of interface simplicity and separation of the “routine” part of writing API
@@ -12,12 +12,13 @@ export declare class AladoServer {
12
12
  private backlog;
13
13
  private readonly logger?;
14
14
  constructor(options: AladoServerOptions);
15
+ get listening(): boolean;
15
16
  get(path: string, context: Context<any>, handler: (request: any) => Response<any> | Promise<Response<any>>): void;
16
17
  post(path: string, context: Context<any>, handler: (request: any) => Response<any> | Promise<Response<any>>): void;
17
18
  put(path: string, context: Context<any>, handler: (request: any) => Response<any> | Promise<Response<any>>): void;
18
19
  patch(path: string, context: Context<any>, handler: (request: any) => Response<any> | Promise<Response<any>>): void;
19
20
  delete(path: string, context: Context<any>, handler: (request: any) => Response<any> | Promise<Response<any>>): void;
20
21
  head(path: string, context: Context<any>, handler: (request: any) => Promise<Response<any>>): void;
21
- start(cb?: (err?: Error) => void): Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
22
- stop(cb: (error?: Error) => void): Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
22
+ start(cb?: (err?: Error) => void): Server;
23
+ stop(cb: (error?: Error) => void): Server;
23
24
  }
@@ -49,6 +49,9 @@ class AladoServer {
49
49
  ...options.serverOptions,
50
50
  });
51
51
  }
52
+ get listening() {
53
+ return this.server.listening;
54
+ }
52
55
  get(path, context, handler) {
53
56
  this.router.use(_const_1.HttpMethod.GET, path, context, handler);
54
57
  }
@@ -68,10 +71,10 @@ class AladoServer {
68
71
  this.router.use(_const_1.HttpMethod.HEAD, path, context, handler);
69
72
  }
70
73
  start(cb) {
71
- return this.server.listen(this.port, this.host, this.backlog, cb);
74
+ return this.listening ? this.server : this.server.listen(this.port, this.host, this.backlog, cb);
72
75
  }
73
76
  stop(cb) {
74
- return this.server.close(cb);
77
+ return this.listening ? this.server.close(cb) : this.server;
75
78
  }
76
79
  }
77
80
  exports.AladoServer = AladoServer;
@@ -1 +1 @@
1
- {"version":3,"file":"alado-server.js","sourceRoot":"","sources":["../../src/alado-server/alado-server.ts"],"names":[],"mappings":";;;AAEA,mCAAsG;AAGtG,qCAAiC;AACjC,uCAA6C;AAC7C,qCAA+D;AAE/D,MAAa,WAAW;IACL,KAAK,CAAS;IACd,MAAM,CAAS;IACf,MAAM,CAAS;IACf,gBAAgB,CAAM;IAC/B,IAAI,CAAS;IACb,IAAI,CAAS;IACb,OAAO,CAAS;IACP,MAAM,CAAqB;IAE5C,YAAY,OAA2B;QACrC,IAAA,8BAAoB,EAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,mBAAU,CAAC;QACzC,IAAI,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC;YAC9B,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,GAAG,IAAA,wBAAc,EAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3E,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAK,OAA6B,CAAC;QAC/D,IAAI,CAAC,gBAAgB,GAAG,EAAE,GAAG,gCAAuB,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC;QAC7F,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAM,CACtB;YACE,IAAI,E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C,EAAE;IACnE,OAAO,cAAc,CAAC,mBAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC;AAFD,oBAEC;AAED,SAAgB,GAAG,CAAC,IAAY,EAAE,UAAgC,EAAE;IAClE,OAAO,cAAc,CAAC,mBAAU,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;AAFD,kBAEC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,UAAgC,EAAE;IACpE,OAAO,cAAc,CAAC,mBAAU,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC;AAFD,sBAEC;AAED,SAAgB,GAAG,CAAC,IAAY,EAAE,UAAgC,EAAE;IAClE,OAAO,cAAc,CAAC,mBAAU,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC;AAFD,kBAEC;AAED,SAAgB,IAAI,CAAC,IAAY,EAAE,UAAgC,EAAE;IACnE,OAAO,cAAc,CAAC,mBAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC;AAFD,oBAEC"}
@@ -1,6 +1,7 @@
1
1
  export * from './initialize-application';
2
2
  export * from './document-property';
3
3
  export * from './validate-property';
4
+ export * from './transform-property';
4
5
  export * from './file-upload-property';
5
6
  export * from './with-auth';
6
7
  export * from './define-request';
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./initialize-application"), exports);
18
18
  __exportStar(require("./document-property"), exports);
19
19
  __exportStar(require("./validate-property"), exports);
20
+ __exportStar(require("./transform-property"), exports);
20
21
  __exportStar(require("./file-upload-property"), exports);
21
22
  __exportStar(require("./with-auth"), exports);
22
23
  __exportStar(require("./define-request"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC;AACpC,yDAAuC;AACvC,8CAA4B;AAC5B,mDAAiC;AACjC,oDAAkC;AAClC,yCAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC;AACpC,uDAAqC;AACrC,yDAAuC;AACvC,8CAA4B;AAC5B,mDAAiC;AACjC,oDAAkC;AAClC,yCAAuB"}
@@ -0,0 +1 @@
1
+ export declare function transformProperty(propertyTransformer: (value: any) => any | Promise<any>): (...args: any[]) => void;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformProperty = void 0;
4
+ const _injector_1 = require("../injector");
5
+ const initialize_injector_1 = require("./initialize-injector");
6
+ function transformProperty(propertyTransformer) {
7
+ (0, initialize_injector_1.initializeInjector)();
8
+ return function (...args) {
9
+ if (!_injector_1.injector.injected.propertyDefinitionsMapping) {
10
+ _injector_1.injector.injected.propertyDefinitionsMapping = {};
11
+ }
12
+ const key = args[0].constructor.name;
13
+ _injector_1.injector.injected.propertyDefinitionsMapping[key] =
14
+ _injector_1.injector.injected.propertyDefinitionsMapping[key] || {};
15
+ _injector_1.injector.injected.propertyDefinitionsMapping[key][args[1]] =
16
+ _injector_1.injector.injected.propertyDefinitionsMapping[key][args[1]] || {};
17
+ _injector_1.injector.injected.propertyDefinitionsMapping[key][args[1]].transform =
18
+ propertyTransformer;
19
+ };
20
+ }
21
+ exports.transformProperty = transformProperty;
22
+ //# sourceMappingURL=transform-property.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-property.js","sourceRoot":"","sources":["../../src/decorators/transform-property.ts"],"names":[],"mappings":";;;AACA,yCAAqC;AACrC,+DAA2D;AAE3D,SAAgB,iBAAiB,CAAC,mBAAuD;IACvF,IAAA,wCAAkB,GAAE,CAAC;IACrB,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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alado",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Extremely fast, lightweight, robust framework for HTTP applications written in Node.js",
5
5
  "keywords": [
6
6
  "HTTP",