@alwatr/nanotron-api-server 4.0.0-alpha.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,418 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 4.0.0-alpha.0 (2024-09-10)
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * everything rewrite from scratch please check the documents
11
+
12
+ Co-authored-by: Mohammad Honarvar <honarvar.info@gmail.com>
13
+
14
+ ### Features
15
+
16
+ * Add applyReplyHeaders_ method to NanotronApiConnection class ([2a0eb4a](https://github.com/Alwatr/nanotron/commit/2a0eb4a1cb02519ad4aea6ad5d4d45de058029c2)) by @AliMD
17
+ * Add close method to NanotronApiServer ([cbd2ed8](https://github.com/Alwatr/nanotron/commit/cbd2ed8bc43fc78027ec8a647659a8ab59e7606c)) by @AliMD
18
+ * Add constructor to NanotronApiConnection class ([71d7a3a](https://github.com/Alwatr/nanotron/commit/71d7a3a51009a53fa7a23e39a3780bbc755038fd)) by @AliMD
19
+ * Add constructor to NanotronApiServer ([fbb358c](https://github.com/Alwatr/nanotron/commit/fbb358c1f2867f3bece25e7cb3cc4b18760e4204)) by @AliMD
20
+ * Add constructor, default configuration, DefineRouteOption interface, and NanotronApiServerConfig interface to NanotronApiServer ([3af3d82](https://github.com/Alwatr/nanotron/commit/3af3d82db4fc7c8d18767d11254aff52691fe8db)) by @AliMD
21
+ * Add default configuration for NanotronApiServer ([19495d0](https://github.com/Alwatr/nanotron/commit/19495d07c0dfb6d5c400ebbbf5beac8aa9236452)) by @AliMD
22
+ * Add defineRoute method to NanotronApiServer ([e1448c9](https://github.com/Alwatr/nanotron/commit/e1448c991c8beae0b8f53a283b2439cc0a826603)) by @AliMD
23
+ * Add DefineRouteOption interface ([f481ecb](https://github.com/Alwatr/nanotron/commit/f481ecb0e71c2d6d04184394f2403fd4ad376113)) by @AliMD
24
+ * Add error handling and request handling to NanotronApiServer ([2fcc6f9](https://github.com/Alwatr/nanotron/commit/2fcc6f943e9f08cd3f83c8d19691b79dbb877ca0)) by @AliMD
25
+ * Add error handling for client errors in NanotronApiServer ([f7667d8](https://github.com/Alwatr/nanotron/commit/f7667d82cb7778943e83e041820d95868866de1b)) by @AliMD
26
+ * Add error handling for HTTP errors in NanotronApiServer ([2a8a87c](https://github.com/Alwatr/nanotron/commit/2a8a87cb0d1aa5d359daab49f3456b34c8ae7984)) by @AliMD
27
+ * Add error handling to handleServerError_ method in NanotronApiServer ([4273478](https://github.com/Alwatr/nanotron/commit/42734788c59dbcac264ea5b75d2a547cac2a33e1)) by @AliMD
28
+ * Add getRouteOption_ method to NanotronApiServer ([4eada32](https://github.com/Alwatr/nanotron/commit/4eada3237cbed77709389bf823d8ed8f5c9259d0)) by @AliMD
29
+ * Add HttpResponseHeaders interface and ErrorResponse type to type.ts ([03fe655](https://github.com/Alwatr/nanotron/commit/03fe655e5f9c8d965948b20ca0d2f5817f78e0f4)) by @AliMD
30
+ * Add HttpResponseHeaders interface to type.ts ([fe971fd](https://github.com/Alwatr/nanotron/commit/fe971fd13a61aee1ee49d3ac2039ca8c5d3cd2d7)) by @AliMD
31
+ * Add HttpStatusCode type to const.ts ([44888c3](https://github.com/Alwatr/nanotron/commit/44888c386fe4d943f2bf78b5ec0ad2f80a4269e8)) by @AliMD
32
+ * Add HttpStatusCodes object to const.ts ([76436bc](https://github.com/Alwatr/nanotron/commit/76436bcda5a64c249b232cae433eb5c93f32d9e4)) by @AliMD
33
+ * Add HttpStatusMessages object to const.ts ([4424261](https://github.com/Alwatr/nanotron/commit/442426170c1cc667a8ac834f4b6d87c28da602ad)) by @AliMD
34
+ * Add MatchType type to type.ts ([21fe834](https://github.com/Alwatr/nanotron/commit/21fe83479483e70ac4f52ca83a479732836dcd4e)) by @AliMD
35
+ * Add NanotronApiConnection class and import dependencies ([ee952a5](https://github.com/Alwatr/nanotron/commit/ee952a5024b40e8f361c791a60e06714f355a4c6)) by @AliMD
36
+ * Add NanotronApiConnectionConfig interface ([995fad1](https://github.com/Alwatr/nanotron/commit/995fad15f92909ee62fb4032e5ad797ac5a45b9f)) by @AliMD
37
+ * Add NanotronApiServerConfig interface ([fe94be3](https://github.com/Alwatr/nanotron/commit/fe94be388d7f97b84ee0878595731e6f85886e6e)) by @AliMD
38
+ * Add reply method to NanotronApiConnection class ([494173c](https://github.com/Alwatr/nanotron/commit/494173c270c645b244a6611947c3f6e7280b4444)) by @AliMD
39
+ * Add replyError method to NanotronApiConnection class ([1489c34](https://github.com/Alwatr/nanotron/commit/1489c3485253db3805ac59ede2ad332191fe45f6)) by @AliMD
40
+ * Add replyHeaders property to NanotronApiConnection ([166f308](https://github.com/Alwatr/nanotron/commit/166f3086d94901a37ae2c5326727aaab3c6236bc)) by @AliMD
41
+ * Add replyJson method to NanotronApiConnection class ([028e6ef](https://github.com/Alwatr/nanotron/commit/028e6eff04e346fd33e9ebeb65c639a8841dabfa)) by @AliMD
42
+ * Add replyJsonError method to NanotronApiConnection class ([5cbb0a7](https://github.com/Alwatr/nanotron/commit/5cbb0a7e444a46d4aec1da469d4b5fe22a81bf97)) by @AliMD
43
+ * Add replySent property to NanotronApiConnection class ([ad955c3](https://github.com/Alwatr/nanotron/commit/ad955c397463dad707b56506eeaaecd3fc350f31)) by @AliMD
44
+ * Add replyStatusCode property to NanotronApiConnection class ([e92d71c](https://github.com/Alwatr/nanotron/commit/e92d71c71d6485bca56784ae43211f11cbf4cdbf)) by @AliMD
45
+ * Add RouteHandler type to type.ts ([0050dc3](https://github.com/Alwatr/nanotron/commit/0050dc3bee94c0d8fc663581f7c801c4782b34ce)) by @AliMD
46
+ * Add setRouteOption_ method to NanotronApiServer ([755cb93](https://github.com/Alwatr/nanotron/commit/755cb934d0ddff81e33436c0f787285e7dd378c8)) by @AliMD
47
+ * Add standard HTTP methods to const.ts ([eb9cf06](https://github.com/Alwatr/nanotron/commit/eb9cf061e557eac88c5b3fcab4f82ea3fb82ee5b)) by @AliMD
48
+ * Add version pattern and logger to NanotronApiConnection ([798af10](https://github.com/Alwatr/nanotron/commit/798af1064cb5a81b819a19b68efbf0aea92d8994)) by @AliMD
49
+ * HttpMethod type ([520ac4f](https://github.com/Alwatr/nanotron/commit/520ac4f8965d67023fafdf8dfcc3fde901462fc0)) by @AliMD
50
+
51
+ ### Code Refactoring
52
+
53
+ * cleanup old nano-server ([0656967](https://github.com/Alwatr/nanotron/commit/06569674be239cca025e7f48810324aed6c03ede)) by @AliMD
54
+ * Import necessary modules and types in api-server.ts ([bd4253f](https://github.com/Alwatr/nanotron/commit/bd4253f4d5f1e7237cbf3a1e4d07e44e628ba2d8)) by @AliMD
55
+ * Remove unused 'client-id' header from IncomingHttpHeaders ([43617d8](https://github.com/Alwatr/nanotron/commit/43617d86189055c41a6f326e101a3dff834c8d28)) by @AliMD
56
+ * Update package description in api-server ([df4df3f](https://github.com/Alwatr/nanotron/commit/df4df3f9e71dcdca4f9f0b53199bf15fcb41fa5a)) by @AliMD
57
+
58
+ ### Miscellaneous Chores
59
+
60
+ * rename http-server to nanotron-api-server ([7dd983e](https://github.com/Alwatr/nanotron/commit/7dd983e41e174349549fcdcf02ee202e74aa4453)) by @AliMD
61
+
62
+ ### Dependencies update
63
+
64
+ * update ([f95134f](https://github.com/Alwatr/nanotron/commit/f95134fe5a4b61ee01eb84450807efb9ef099010)) by @AliMD
65
+
66
+ ## [1.2.7](https://github.com/Alwatr/alwatr-es-sdk/compare/@alwatr/nano-server@1.2.6...@alwatr/nano-server@1.2.7) (2023-12-19)
67
+
68
+ **Note:** Version bump only for package @alwatr/nano-server
69
+
70
+ ## [1.2.6](https://github.com/Alwatr/alwatr-es-sdk/compare/@alwatr/nano-server@1.2.5...@alwatr/nano-server@1.2.6) (2023-12-19)
71
+
72
+ **Note:** Version bump only for package @alwatr/nano-server
73
+
74
+ ## [1.2.5](https://github.com/Alwatr/alwatr-es-sdk/compare/@alwatr/nano-server@1.2.4...@alwatr/nano-server@1.2.5) (2023-12-11)
75
+
76
+ **Note:** Version bump only for package @alwatr/nano-server
77
+
78
+ ## [1.2.4](https://github.com/Alwatr/alwatr-es-sdk/compare/@alwatr/nano-server@1.2.3...@alwatr/nano-server@1.2.4) (2023-12-11)
79
+
80
+ **Note:** Version bump only for package @alwatr/nano-server
81
+
82
+ ## [1.2.3](https://github.com/Alwatr/alwatr-es-sdk/compare/@alwatr/nano-server@1.2.2...@alwatr/nano-server@1.2.3) (2023-12-09)
83
+
84
+ **Note:** Version bump only for package @alwatr/nano-server
85
+
86
+ ## [1.2.2](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.2.1...@alwatr/nano-server@1.2.2) (2023-11-29)
87
+
88
+ **Note:** Version bump only for package @alwatr/nano-server
89
+
90
+ ## [1.2.1](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.2.0...@alwatr/nano-server@1.2.1) (2023-11-23)
91
+
92
+ **Note:** Version bump only for package @alwatr/nano-server
93
+
94
+ # [1.2.0](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.1.12...@alwatr/nano-server@1.2.0) (2023-11-14)
95
+
96
+ ### Features
97
+
98
+ * **yarn:** pnp ([b6a562c](https://github.com/Alwatr/eslib/commit/b6a562c909a35b3e626442e5c325da3fce448e1b)) by @AliMD
99
+
100
+ ## [1.1.12](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.1.11...@alwatr/nano-server@1.1.12) (2023-11-08)
101
+
102
+ ### Bug Fixes
103
+
104
+ * move repo urls ([719aa3e](https://github.com/Alwatr/eslib/commit/719aa3e7462d3c9c6272958fc93f89fda6793fb1)) by @AliMD
105
+
106
+ ## [1.1.11](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.1.10...@alwatr/nano-server@1.1.11) (2023-11-01)
107
+
108
+ **Note:** Version bump only for package @alwatr/nano-server
109
+
110
+ ## [1.1.10](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.1.9...@alwatr/nano-server@1.1.10) (2023-10-23)
111
+
112
+ **Note:** Version bump only for package @alwatr/nano-server
113
+
114
+ ## [1.1.9](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.1.8...@alwatr/nano-server@1.1.9) (2023-10-23)
115
+
116
+ **Note:** Version bump only for package @alwatr/nano-server
117
+
118
+ ## [1.1.8](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.1.7...@alwatr/nano-server@1.1.8) (2023-10-23)
119
+
120
+ ### Bug Fixes
121
+
122
+ * **nano-server:** compatible with new logger api ([ecace8b](https://github.com/Alwatr/eslib/commit/ecace8bd5b0007e605c7e4eeebc1c1806d8f84d6)) by @AliMD
123
+
124
+ ## [1.1.7](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.1.6...@alwatr/nano-server@1.1.7) (2023-10-23)
125
+
126
+ **Note:** Version bump only for package @alwatr/nano-server
127
+
128
+ ## [1.1.6](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.1.5...@alwatr/nano-server@1.1.6) (2023-10-23)
129
+
130
+ **Note:** Version bump only for package @alwatr/nano-server
131
+
132
+ ## [1.1.5](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.1.4...@alwatr/nano-server@1.1.5) (2023-09-19)
133
+
134
+ ### Bug Fixes
135
+
136
+ - package repo urls ([466cbe9](https://github.com/Alwatr/eslib/commit/466cbe9188f24e1a1bc36d879a95b52538a58f16)) by @AliMD
137
+
138
+ ## [1.1.4](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.1.3...@alwatr/nano-server@1.1.4) (2023-09-19)
139
+
140
+ **Note:** Version bump only for package @alwatr/nano-server
141
+
142
+ ## 1.1.3 (2023-09-19)
143
+
144
+ **Note:** Version bump only for package @alwatr/nano-server
145
+
146
+ ## [1.1.2](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.1.1...@alwatr/nano-server@1.1.2) (2023-09-12)
147
+
148
+ **Note:** Version bump only for package @alwatr/nano-server
149
+
150
+ ## [1.1.1](https://github.com/Alwatr/eslib/compare/@alwatr/nano-server@1.1.0...@alwatr/nano-server@1.1.1) (2023-09-12)
151
+
152
+ **Note:** Version bump only for package @alwatr/nano-server
153
+
154
+ # 1.1.0 (2023-09-12)
155
+
156
+ # 1.0.0 (2023-06-14)
157
+
158
+ # 0.32.0 (2023-05-27)
159
+
160
+ ### Bug Fixes
161
+
162
+ - **nano-server:** `data` type ([f629f3b](https://github.com/Alwatr/eslib/commit/f629f3b7952b775ead78119c699ce93c119b8164))
163
+
164
+ # 0.31.0 (2023-05-08)
165
+
166
+ ### Bug Fixes
167
+
168
+ - **nano-server:** path prefix ([83995f7](https://github.com/Alwatr/eslib/commit/83995f7bc9748ecb632d6f8dbea5e2f96fa59c41))
169
+ - **nano-server:** prefixPattern, logger ([f9d203e](https://github.com/Alwatr/eslib/commit/f9d203e65955629f6dd5c468867f20ce578337eb))
170
+ - new logger api ([9d83a7d](https://github.com/Alwatr/eslib/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
171
+
172
+ ### Features
173
+
174
+ - **nano-server:** add getUserAuth ([615266f](https://github.com/Alwatr/eslib/commit/615266f06ef47a7a5b36fe3d6abee1653703bf6f))
175
+ - **nano-server:** prefix pattern ([ad5e1b5](https://github.com/Alwatr/eslib/commit/ad5e1b56651c96cb825187604f877fee396b3ec4))
176
+
177
+ # 0.30.0 (2023-03-06)
178
+
179
+ ### Features
180
+
181
+ - **nano-server:** getRemoteAddress ([eff82cb](https://github.com/Alwatr/eslib/commit/eff82cbdba5a35a88d95f6997365210683163d62))
182
+ - **nano-server:** requireClientId ([fccd734](https://github.com/Alwatr/eslib/commit/fccd734f0c08cc624492b30e14c451143706cc00))
183
+
184
+ # 0.29.0 (2023-02-10)
185
+
186
+ ### Bug Fixes
187
+
188
+ - **nano-server:** compatible with ParamValueType ([325d896](https://github.com/Alwatr/eslib/commit/325d89651aeba38079d6fb9184adb894df94f083))
189
+ - **nano-server:** null parsedParams ([bb969b2](https://github.com/Alwatr/eslib/commit/bb969b23495f791003225b5c557e40e10e7f8124))
190
+ - **nano-server:** type ([2586061](https://github.com/Alwatr/eslib/commit/25860611f765e67ecddd586d80169ebe7f75701b))
191
+
192
+ ### Features
193
+
194
+ - **nano-server:** add client-id to IncomingHttpHeaders type ([a4a86c7](https://github.com/Alwatr/eslib/commit/a4a86c7e410edfe69e66cdab6b8ffdc0d9b95eb8))
195
+ - **nano-service:** api prefix support ([21960dc](https://github.com/Alwatr/eslib/commit/21960dce5f25a587b19886e487f7d46af5ca087b))
196
+
197
+ # 0.28.0 (2023-01-20)
198
+
199
+ ### Bug Fixes
200
+
201
+ - **nano-server:** math references ([e46071a](https://github.com/Alwatr/eslib/commit/e46071a49bb61cb6f36d2e79e14c32712f3746fa))
202
+ - **type:** revert paramkey ([f1ad066](https://github.com/Alwatr/eslib/commit/f1ad06621f7fe80018573e50804e9f3c1b2edde1))
203
+
204
+ # 0.27.0 (2022-12-29)
205
+
206
+ ### Bug Fixes
207
+
208
+ - review issue ([e5d192c](https://github.com/Alwatr/eslib/commit/e5d192cbee6917c2de01146cf8bd026895724ab8))
209
+
210
+ # 0.26.0 (2022-12-22)
211
+
212
+ ### Bug Fixes
213
+
214
+ - inline home route ([ce978f6](https://github.com/Alwatr/eslib/commit/ce978f6e1e2890e853d0db351c08efca665e5fad))
215
+ - **nano-server:** check method on getBody ([9aa9857](https://github.com/Alwatr/eslib/commit/9aa9857fb6ad96f861f31c651bf131813e46b343))
216
+ - **nano-server:** handle utf8 reply issue ([33aa238](https://github.com/Alwatr/eslib/commit/33aa238d99f92c03a5b39e829cb39172dc45d5c6))
217
+ - **nano-server:** remove return null on requireToken ([3c6779f](https://github.com/Alwatr/eslib/commit/3c6779f6b114aa1afe71e9b2054fb6dbe273c26a))
218
+ - **nano-server:** route generic ([94e181b](https://github.com/Alwatr/eslib/commit/94e181ba1172399ac992af6dc969c56e4edffbf0))
219
+ - **nano-server:** update docs and return type ([df949c1](https://github.com/Alwatr/eslib/commit/df949c19ea75921ab9c3e7323dc33ef340bd3ee7))
220
+ - set correct path ([d01ce6f](https://github.com/Alwatr/eslib/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9))
221
+ - tsconfig ([e96dcd3](https://github.com/Alwatr/eslib/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35))
222
+
223
+ ### Features
224
+
225
+ - improve accident debugging ([d697e6c](https://github.com/Alwatr/eslib/commit/d697e6c4c7d0a4172f4dba9caf6fbd478f79de9c))
226
+ - improve error debugging ([1fba504](https://github.com/Alwatr/eslib/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c))
227
+ - **nano-server:** clear debug info from client for security reasons. ([5814af2](https://github.com/Alwatr/eslib/commit/5814af2ceeac6e2175c4ab924e4b40cef765072c))
228
+ - **nano-server:** maybe promise type ([d782761](https://github.com/Alwatr/eslib/commit/d7827616ea71b7e6328c6a85b80c2daec0b6f512))
229
+ - **nano-server:** reply throw on route ([083dfa5](https://github.com/Alwatr/eslib/commit/083dfa51b391dc689d1d4fed9f1f17d768e7384c))
230
+ - **nano-server:** routeMiddleware type ([a05b1a2](https://github.com/Alwatr/eslib/commit/a05b1a2bc79aeca67a81f4758f5d2b0f6c890028))
231
+
232
+ # [1.0.0](https://github.com/Alwatr/eslib/compare/v0.32.0...v1.0.0) (2023-06-14)
233
+
234
+ **Note:** Version bump only for package @alwatr/nano-server
235
+
236
+ # [0.32.0](https://github.com/Alwatr/eslib/compare/v0.31.0...v0.32.0) (2023-05-27)
237
+
238
+ ### Bug Fixes
239
+
240
+ - **nano-server:** `data` type ([f629f3b](https://github.com/Alwatr/eslib/commit/f629f3b7952b775ead78119c699ce93c119b8164))
241
+
242
+ # [0.31.0](https://github.com/Alwatr/eslib/compare/v0.30.0...v0.31.0) (2023-05-08)
243
+
244
+ ### Bug Fixes
245
+
246
+ - **nano-server:** path prefix ([83995f7](https://github.com/Alwatr/eslib/commit/83995f7bc9748ecb632d6f8dbea5e2f96fa59c41))
247
+ - **nano-server:** prefixPattern, logger ([f9d203e](https://github.com/Alwatr/eslib/commit/f9d203e65955629f6dd5c468867f20ce578337eb))
248
+ - new logger api ([9d83a7d](https://github.com/Alwatr/eslib/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300))
249
+
250
+ ### Features
251
+
252
+ - **nano-server:** add getUserAuth ([615266f](https://github.com/Alwatr/eslib/commit/615266f06ef47a7a5b36fe3d6abee1653703bf6f))
253
+ - **nano-server:** prefix pattern ([ad5e1b5](https://github.com/Alwatr/eslib/commit/ad5e1b56651c96cb825187604f877fee396b3ec4))
254
+
255
+ # [0.30.0](https://github.com/Alwatr/eslib/compare/v0.29.0...v0.30.0) (2023-03-06)
256
+
257
+ ### Features
258
+
259
+ - **nano-server:** getRemoteAddress ([eff82cb](https://github.com/Alwatr/eslib/commit/eff82cbdba5a35a88d95f6997365210683163d62))
260
+ - **nano-server:** requireClientId ([fccd734](https://github.com/Alwatr/eslib/commit/fccd734f0c08cc624492b30e14c451143706cc00))
261
+
262
+ # [0.29.0](https://github.com/Alwatr/eslib/compare/v0.28.0...v0.29.0) (2023-02-10)
263
+
264
+ ### Bug Fixes
265
+
266
+ - **nano-server:** compatible with ParamValueType ([325d896](https://github.com/Alwatr/eslib/commit/325d89651aeba38079d6fb9184adb894df94f083))
267
+ - **nano-server:** null parsedParams ([bb969b2](https://github.com/Alwatr/eslib/commit/bb969b23495f791003225b5c557e40e10e7f8124))
268
+ - **nano-server:** type ([2586061](https://github.com/Alwatr/eslib/commit/25860611f765e67ecddd586d80169ebe7f75701b))
269
+
270
+ ### Features
271
+
272
+ - **nano-server:** add client-id to IncomingHttpHeaders type ([a4a86c7](https://github.com/Alwatr/eslib/commit/a4a86c7e410edfe69e66cdab6b8ffdc0d9b95eb8))
273
+ - **nano-service:** api prefix support ([21960dc](https://github.com/Alwatr/eslib/commit/21960dce5f25a587b19886e487f7d46af5ca087b))
274
+
275
+ # [0.28.0](https://github.com/Alwatr/eslib/compare/v0.27.0...v0.28.0) (2023-01-20)
276
+
277
+ ### Bug Fixes
278
+
279
+ - **nano-server:** math references ([e46071a](https://github.com/Alwatr/eslib/commit/e46071a49bb61cb6f36d2e79e14c32712f3746fa))
280
+ - review issue ([e5d192c](https://github.com/Alwatr/eslib/commit/e5d192cbee6917c2de01146cf8bd026895724ab8))
281
+ - **type:** revert paramkey ([f1ad066](https://github.com/Alwatr/eslib/commit/f1ad06621f7fe80018573e50804e9f3c1b2edde1))
282
+
283
+ # [0.27.0](https://github.com/Alwatr/eslib/compare/v0.26.0...v0.27.0) (2022-12-29)
284
+
285
+ **Note:** Version bump only for package @alwatr/nano-server
286
+
287
+ # [0.26.0](https://github.com/Alwatr/eslib/compare/v0.25.0...v0.26.0) (2022-12-22)
288
+
289
+ ### Bug Fixes
290
+
291
+ - inline home route ([ce978f6](https://github.com/Alwatr/eslib/commit/ce978f6e1e2890e853d0db351c08efca665e5fad))
292
+ - **nano-server:** check method on getBody ([9aa9857](https://github.com/Alwatr/eslib/commit/9aa9857fb6ad96f861f31c651bf131813e46b343))
293
+ - **nano-server:** handle utf8 reply issue ([33aa238](https://github.com/Alwatr/eslib/commit/33aa238d99f92c03a5b39e829cb39172dc45d5c6))
294
+ - **nano-server:** remove return null on requireToken ([3c6779f](https://github.com/Alwatr/eslib/commit/3c6779f6b114aa1afe71e9b2054fb6dbe273c26a))
295
+ - **nano-server:** route generic ([94e181b](https://github.com/Alwatr/eslib/commit/94e181ba1172399ac992af6dc969c56e4edffbf0))
296
+ - **nano-server:** update docs and return type ([df949c1](https://github.com/Alwatr/eslib/commit/df949c19ea75921ab9c3e7323dc33ef340bd3ee7))
297
+ - set correct path ([d01ce6f](https://github.com/Alwatr/eslib/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9))
298
+ - tsconfig ([e96dcd3](https://github.com/Alwatr/eslib/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35))
299
+
300
+ ### Features
301
+
302
+ - improve accident debugging ([d697e6c](https://github.com/Alwatr/eslib/commit/d697e6c4c7d0a4172f4dba9caf6fbd478f79de9c))
303
+ - improve error debugging ([1fba504](https://github.com/Alwatr/eslib/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c))
304
+ - **nano-server:** clear debug info from client for security reasons. ([5814af2](https://github.com/Alwatr/eslib/commit/5814af2ceeac6e2175c4ab924e4b40cef765072c))
305
+ - **nano-server:** maybe promise type ([d782761](https://github.com/Alwatr/eslib/commit/d7827616ea71b7e6328c6a85b80c2daec0b6f512))
306
+ - **nano-server:** reply throw on route ([083dfa5](https://github.com/Alwatr/eslib/commit/083dfa51b391dc689d1d4fed9f1f17d768e7384c))
307
+ - **nano-server:** routeMiddleware type ([a05b1a2](https://github.com/Alwatr/eslib/commit/a05b1a2bc79aeca67a81f4758f5d2b0f6c890028))
308
+
309
+ # [0.25.0](https://github.com/Alwatr/eslib/compare/v0.24.1...v0.25.0) (2022-12-07)
310
+
311
+ **Note:** Version bump only for package @alwatr/nano-server
312
+
313
+ ## [0.24.1](https://github.com/Alwatr/eslib/compare/v0.24.0...v0.24.1) (2022-12-01)
314
+
315
+ **Note:** Version bump only for package @alwatr/nano-server
316
+
317
+ # [0.24.0](https://github.com/Alwatr/eslib/compare/v0.23.0...v0.24.0) (2022-11-28)
318
+
319
+ ### Bug Fixes
320
+
321
+ - **demo:** update types ([010b123](https://github.com/Alwatr/eslib/commit/010b123075d073c8583f557608a9781064d7cc5c))
322
+ - **nano-server:** \_sanitizeParam types ([bd4f39d](https://github.com/Alwatr/eslib/commit/bd4f39d32ceef5f2be26fce27a37cc7e1d5f6bd6))
323
+ - **nano-server:** deps ([ea0ceba](https://github.com/Alwatr/eslib/commit/ea0ceba7da3d1bc0542d9eb69d951aa3c3165175))
324
+ - **nano-server:** handle preflight request ([ab575cd](https://github.com/Alwatr/eslib/commit/ab575cd67b3f06dc64c895a7080e766b02ee3c22))
325
+ - **nano-server:** use config for cors ([947dad9](https://github.com/Alwatr/eslib/commit/947dad9473d7408aad9a4640ffdd2157edae10c5))
326
+ - use ~ for package version ([4e027ff](https://github.com/Alwatr/eslib/commit/4e027ff63875e03b088ebcdc1bdf2495f4494eec))
327
+
328
+ # [0.23.0](https://github.com/Alwatr/eslib/compare/v0.22.1...v0.23.0) (2022-11-23)
329
+
330
+ ### Bug Fixes
331
+
332
+ - **nano-server:** getToken ([a2f1ccb](https://github.com/Alwatr/eslib/commit/a2f1ccbe5d81d3f284ba1ce80dd2e54ec2245848))
333
+
334
+ ## [0.22.1](https://github.com/Alwatr/eslib/compare/v0.22.0...v0.22.1) (2022-11-21)
335
+
336
+ ### Bug Fixes
337
+
338
+ - add rest client extension to recommendation ([33a4a25](https://github.com/Alwatr/eslib/commit/33a4a2579208d6026380bbe8eaa9d4f9d2a8a1b9))
339
+
340
+ # [0.22.0](https://github.com/Alwatr/eslib/compare/v0.21.0...v0.22.0) (2022-11-20)
341
+
342
+ ### Bug Fixes
343
+
344
+ - **nano-server:** method all ([b20afa1](https://github.com/Alwatr/eslib/commit/b20afa1fb8eeb13c4b6e3d811ae6fbbeb7465306))
345
+ - **nano-server:** no-non-null-assertion ([ad5588c](https://github.com/Alwatr/eslib/commit/ad5588c6e0e863aa03cca44c23144dbf371795da))
346
+ - **nano-server:** parse body on PATCH method ([cba790f](https://github.com/Alwatr/eslib/commit/cba790f43dc88c00ee99f5f7d7c872e8f6d1618d))
347
+ - **nano-server:** remove ALL from Methods type ([1f67c07](https://github.com/Alwatr/eslib/commit/1f67c07a5044c6d7cf89605e269af468aa49094c))
348
+ - **nano-server:** review require... methods and fix issues ([a7e4bae](https://github.com/Alwatr/eslib/commit/a7e4bae89440c2fc72a0a9e6060aac894b18eddf))
349
+ - **services/storage:** remove home route ([5b4160d](https://github.com/Alwatr/eslib/commit/5b4160df0237085e43a103a02b9b63404eddda2c))
350
+
351
+ ### Features
352
+
353
+ - **nano-server:** add \_sanitizeParam ([46edbc3](https://github.com/Alwatr/eslib/commit/46edbc33eb164f6676d8a5c939d52accededfd45))
354
+ - **nano-server:** keep alive performance and options ([5ed78b6](https://github.com/Alwatr/eslib/commit/5ed78b6cf5b7fd1b00c28df26ca250d4025dc676))
355
+ - **nano-server:** parse and validate query params in AlwatrConnection ([1eadd68](https://github.com/Alwatr/eslib/commit/1eadd68d3e1f92e47d743b7412ae247f3414738f))
356
+ - **nano-server:** validate content type header in requireJsonBody ([d99eb74](https://github.com/Alwatr/eslib/commit/d99eb742c0c5ea1b92f44767d570bd42b9c9e342))
357
+ - **services/storage:** add remove route ([d4452cd](https://github.com/Alwatr/eslib/commit/d4452cd0366452ab07d82b338dbba345c32cd61d))
358
+ - **services/storage:** add requireToken to AlwatrConnection ([8073773](https://github.com/Alwatr/eslib/commit/8073773577b88a52baa90c6042bac52260ec3dc1))
359
+
360
+ ### Performance Improvements
361
+
362
+ - **nano-server:** faster log ([8ff716e](https://github.com/Alwatr/eslib/commit/8ff716e1eaee59047f816e1645aa9dde7635b571))
363
+
364
+ # [0.21.0](https://github.com/Alwatr/eslib/compare/v0.20.0...v0.21.0) (2022-11-13)
365
+
366
+ **Note:** Version bump only for package @alwatr/nano-server
367
+
368
+ # [0.20.0](https://github.com/Alwatr/eslib/compare/v0.19.0...v0.20.0) (2022-11-05)
369
+
370
+ **Note:** Version bump only for package @alwatr/nano-server
371
+
372
+ # [0.19.0](https://github.com/Alwatr/eslib/compare/v0.18.0...v0.19.0) (2022-11-01)
373
+
374
+ **Note:** Version bump only for package @alwatr/nano-server
375
+
376
+ # [0.18.0](https://github.com/Alwatr/eslib/compare/v0.17.0...v0.18.0) (2022-10-22)
377
+
378
+ **Note:** Version bump only for package @alwatr/nano-server
379
+
380
+ # [0.17.0](https://github.com/Alwatr/eslib/compare/v0.16.1...v0.17.0) (2022-10-21)
381
+
382
+ **Note:** Version bump only for package @alwatr/nano-server
383
+
384
+ # [0.16.0](https://github.com/Alwatr/eslib/compare/v0.15.0...v0.16.0) (2022-09-08)
385
+
386
+ **Note:** Version bump only for package @alwatr/nano-server
387
+
388
+ # [0.15.0](https://github.com/Alwatr/eslib/compare/v0.14.0...v0.15.0) (2022-09-01)
389
+
390
+ **Note:** Version bump only for package @alwatr/nano-server
391
+
392
+ # [0.14.0](https://github.com/Alwatr/eslib/compare/v0.13.0...v0.14.0) (2022-08-19)
393
+
394
+ **Note:** Version bump only for package @alwatr/nano-server
395
+
396
+ # [0.13.0](https://github.com/Alwatr/eslib/compare/v0.12.0...v0.13.0) (2022-08-06)
397
+
398
+ ### Bug Fixes
399
+
400
+ - **nano-server:** `incomingMessage` body ([0172390](https://github.com/Alwatr/eslib/commit/01723906f657c35a7a2a329b914308c3d9f06ff8))
401
+ - **nano-server:** host log ([c0c0f97](https://github.com/Alwatr/eslib/commit/c0c0f971d0405f5731cf040962b4609c9472a2fc))
402
+ - **nano-server:** logs ([72cb160](https://github.com/Alwatr/eslib/commit/72cb160b53e7bb04be6b5d24aa04f98d6a597e11))
403
+
404
+ ### Features
405
+
406
+ - **nano-server:** add token to connection ([8677999](https://github.com/Alwatr/eslib/commit/867799920c917dbafe3a041a8946f7e77577552f))
407
+ - **nano-server:** refactor, add seperate config, cache all routes ([2cdd203](https://github.com/Alwatr/eslib/commit/2cdd2030474b7c1796e311740f20b8f39631bae9))
408
+
409
+ # [0.12.0](https://github.com/Alwatr/eslib/compare/v0.11.0...v0.12.0) (2022-07-22)
410
+
411
+ ### Bug Fixes
412
+
413
+ - **nano-server:** logger scope ([73dbf02](https://github.com/Alwatr/eslib/commit/73dbf029325169d900558e2361fec9fa4303e7e4))
414
+
415
+ ### Features
416
+
417
+ - **nano-server:** make `statusCode` in `ReplySuccessContent` optional ([fe836f4](https://github.com/Alwatr/eslib/commit/fe836f452566c541d25857df34c952b413690d23))
418
+ - **nano-server:** make new package ([2148dfc](https://github.com/Alwatr/eslib/commit/2148dfc910565f917d3cb8eb001cde08f2fc694d))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 S. Ali Mihandoost
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # Alwatr Nanotron Api Server
2
+
3
+ Nanotron: Your Lightweight, High-Performance Micro/Nano Service Framework.
4
+
5
+ ## Example usage
6
+
7
+ ```ts
8
+ import {type AlwatrConnection, AlwatrNanoServer} from 'https://esm.run/@alwatr/nano-server';
9
+
10
+ const nanoServer = new AlwatrNanoServer();
11
+
12
+ nanoServer.route('GET', '/', async (connection: AlwatrConnection) => {
13
+ connection.reply({
14
+ ok: true,
15
+ data: {
16
+ app: 'Alwatr Nanoservice Starter Kit',
17
+ message: 'Hello ;)',
18
+ },
19
+ });
20
+ });
21
+ ```
22
+
23
+ ## API
24
+
25
+ ### `AlwatrNanoServer(config?: Partial<Config>)`
26
+
27
+ Create a server for nanoservice use cases.
28
+
29
+ Example:
30
+
31
+ ```ts
32
+ import {AlwatrNanoServer} from 'https://esm.run/@alwatr/nano-server';
33
+ const nanoServer = new AlwatrNanoServer();
34
+ ```
35
+
36
+ ### `nanoserver.close()`
37
+
38
+ Stops the HTTP server from accepting new connections.
39
+
40
+ ### `route(method: Methods, route: 'all' |`/${string}`,middleware: (connection: AlwatrConnection) => void)`
41
+
42
+ Refers to how an application’s endpoints (URIs) respond to client requests.
43
+
44
+ Example:
45
+
46
+ ```ts
47
+ nanoServer.route('GET', '/', middleware);
48
+ ```
49
+
50
+ ### `AlwatrConnection(incomingMessage: IncomingMessage, serverResponse: ServerResponse)`
51
+
52
+ ????
53
+
54
+ ```ts
55
+ async function middleware(connection: AlwatrConnection) => {
56
+ connection.reply({
57
+ ok: true,
58
+ data: {
59
+ app: 'Alwatr Nanoservice Starter Kit',
60
+ message: 'Hello ;)',
61
+ },
62
+ });
63
+ });
64
+ ```
65
+
66
+ ### `connection.url: URL`
67
+
68
+ Request URL.
69
+
70
+ ### `connection.method: "ALL" | "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "CONNECT" | "TRACE" | "OPTIONS" | "PATCH"
71
+
72
+ `
73
+
74
+ Request method.
75
+
76
+ ### `connection.getBody(): Promise<string | null>`
77
+
78
+ Get request body for **POST**, **PUT** and **POST** methods..
79
+
80
+ Example:
81
+
82
+ ```ts
83
+ const body = await connection.getBody();
84
+ ```
85
+
86
+ ### `connection.getToken(): string | null`
87
+
88
+ Get the token placed in the request header.
89
+
90
+ ### `connection.reply(content: ReplyContent)`
91
+
92
+ Example:
93
+
94
+ ```ts
95
+ nanoServer.route('GET', '/', async (connection) => {
96
+ connection.reply({
97
+ ok: true,
98
+ data: {
99
+ app: 'Alwatr Nanoservice Starter Kit',
100
+ message: 'Hello ;)',
101
+ },
102
+ });
103
+ });
104
+ ```
105
+
106
+ ### `connection.requireJsonBody()`
107
+
108
+ Parse request body.
109
+
110
+ Example:
111
+
112
+ ```ts
113
+ const bodyData = await connection.requireJsonBody();
114
+ if (bodyData == null) return;
115
+ ```
116
+
117
+ ### `requireToken(validator: ((token: string) => boolean) | Array<string> | string): string | null`
118
+
119
+ Parse and validate request token.
120
+ Returns request token.
121
+
122
+ Example:
123
+
124
+ ```ts
125
+ const token = connection.requireToken((token) => token.length > 12);
126
+ if (token == null) return;
127
+ ```
128
+
129
+ ### `requireQueryParams<T>(params: Record<string, ParamType>): T | null`
130
+
131
+ Parse and validate query params.
132
+ Returns query params object.
133
+
134
+ Example:
135
+
136
+ ```ts
137
+ const params = connection.requireQueryParams<{id: string}>({id: 'string'});
138
+ if (params == null) return;
139
+ console.log(params.id);
140
+ ```
@@ -0,0 +1,36 @@
1
+ import { type HttpStatusCode } from './const.js';
2
+ import type { HttpResponseHeaders, HttpMethod, ErrorResponse } from './type.js';
3
+ import type { Json } from '@alwatr/type-helper';
4
+ import type { IncomingMessage, ServerResponse } from 'node:http';
5
+ /**
6
+ * Configuration options for the NanotronApiConnection.
7
+ */
8
+ export interface NanotronApiConnectionConfig {
9
+ /**
10
+ * A prefix to be added to the beginning of the `url` of all defined routes.
11
+ *
12
+ * @default '/api/'
13
+ */
14
+ prefix: `/${string}/` | '/';
15
+ }
16
+ export declare class NanotronApiConnection {
17
+ incomingMessage: IncomingMessage;
18
+ serverResponse: ServerResponse;
19
+ protected config_: NanotronApiConnectionConfig;
20
+ protected static versionPattern_: RegExp;
21
+ readonly url: URL;
22
+ readonly method: HttpMethod;
23
+ protected readonly logger_: import("@alwatr/logger").AlwatrLogger;
24
+ readonly replyHeaders: HttpResponseHeaders;
25
+ protected replySent_: boolean;
26
+ get replySent(): boolean;
27
+ constructor(incomingMessage: IncomingMessage, serverResponse: ServerResponse, config_: NanotronApiConnectionConfig);
28
+ get replyStatusCode(): HttpStatusCode;
29
+ set replyStatusCode(value: HttpStatusCode);
30
+ protected applyReplyHeaders_(): void;
31
+ replyJsonError(errorResponse: ErrorResponse): void;
32
+ replyJson(responseJson: Json): void;
33
+ replyError(error?: Error | unknown): void;
34
+ reply(context: string | Buffer): void;
35
+ }
36
+ //# sourceMappingURL=api-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-connection.d.ts","sourceRoot":"","sources":["../src/api-connection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,cAAc,EAAsC,MAAM,YAAY,CAAC;AAEpF,OAAO,KAAK,EAAC,mBAAmB,EAAE,UAAU,EAAE,aAAa,EAAC,MAAM,WAAW,CAAC;AAC9E,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAAC,eAAe,EAAE,cAAc,EAAC,MAAM,WAAW,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,MAAM,EAAE,IAAI,MAAM,GAAG,GAAG,GAAG,CAAC;CAC7B;AAED,qBAAa,qBAAqB;IAiBvB,eAAe,EAAE,eAAe;IAChC,cAAc,EAAE,cAAc;IACrC,SAAS,CAAC,OAAO,EAAE,2BAA2B;IAlBhD,SAAS,CAAC,MAAM,CAAC,eAAe,SAA4B;IAE5D,QAAQ,CAAC,GAAG,MAAC;IAEb,QAAQ,CAAC,MAAM,aAAC;IAEhB,SAAS,CAAC,QAAQ,CAAC,OAAO,wCAAC;IAE3B,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAE3C,SAAS,CAAC,UAAU,UAAS;IAC7B,IAAI,SAAS,IAAI,OAAO,CAEvB;gBAGQ,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAC3B,OAAO,EAAE,2BAA2B;IAwBhD,IAAI,eAAe,IAAI,cAAc,CAEpC;IAED,IAAI,eAAe,CAAC,KAAK,EAAE,cAAc,EAExC;IAED,SAAS,CAAC,kBAAkB;IAO5B,cAAc,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI;IAKlD,SAAS,CAAC,YAAY,EAAE,IAAI,GAAG,IAAI;IAwBnC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,IAAI;IAqBzC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CA6BtC"}