@prosopo/api-express-router 3.0.33 → 3.0.39
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 +63 -0
- package/package.json +9 -9
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -245
- package/coverage/coverage-final.json +0 -8
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -146
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/coverage/src/apiExpressRouterFactory.ts.html +0 -289
- package/coverage/src/endpointAdapter/apiExpressDefaultEndpointAdapter.ts.html +0 -268
- package/coverage/src/endpointAdapter/apiExpressEndpointAdapter.ts.html +0 -169
- package/coverage/src/endpointAdapter/index.html +0 -131
- package/coverage/src/errorHandler.ts.html +0 -184
- package/coverage/src/index.html +0 -146
- package/coverage/src/index.ts.html +0 -196
- package/coverage/src/middlewares/authMiddleware.ts.html +0 -454
- package/coverage/src/middlewares/index.html +0 -131
- package/coverage/src/middlewares/requestLoggerMiddleware.ts.html +0 -211
- package/dist/apiExpressRouterFactory.d.ts +0 -9
- package/dist/apiExpressRouterFactory.d.ts.map +0 -1
- package/dist/apiExpressRouterFactory.js.map +0 -1
- package/dist/endpointAdapter/apiExpressDefaultEndpointAdapter.d.ts +0 -13
- package/dist/endpointAdapter/apiExpressDefaultEndpointAdapter.d.ts.map +0 -1
- package/dist/endpointAdapter/apiExpressDefaultEndpointAdapter.js.map +0 -1
- package/dist/endpointAdapter/apiExpressEndpointAdapter.d.ts +0 -8
- package/dist/endpointAdapter/apiExpressEndpointAdapter.d.ts.map +0 -1
- package/dist/endpointAdapter/apiExpressEndpointAdapter.js +0 -2
- package/dist/endpointAdapter/apiExpressEndpointAdapter.js.map +0 -1
- package/dist/errorHandler.d.ts +0 -5
- package/dist/errorHandler.d.ts.map +0 -1
- package/dist/errorHandler.js.map +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/middlewares/authMiddleware.d.ts +0 -5
- package/dist/middlewares/authMiddleware.d.ts.map +0 -1
- package/dist/middlewares/authMiddleware.js.map +0 -1
- package/dist/middlewares/requestLoggerMiddleware.d.ts +0 -4
- package/dist/middlewares/requestLoggerMiddleware.d.ts.map +0 -1
- package/dist/middlewares/requestLoggerMiddleware.js.map +0 -1
- package/dist/tests/unit/errorHandler.unit.test.d.ts +0 -2
- package/dist/tests/unit/errorHandler.unit.test.d.ts.map +0 -1
- package/dist/tests/unit/errorHandler.unit.test.js +0 -140
- package/dist/tests/unit/errorHandler.unit.test.js.map +0 -1
- package/dist/tests/unit/middlewares/authMiddleware.unit.test.d.ts +0 -2
- package/dist/tests/unit/middlewares/authMiddleware.unit.test.d.ts.map +0 -1
- package/dist/tests/unit/middlewares/authMiddleware.unit.test.js +0 -135
- package/dist/tests/unit/middlewares/authMiddleware.unit.test.js.map +0 -1
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for src/apiExpressRouterFactory.ts</title>
|
|
7
|
-
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="../prettify.css" />
|
|
9
|
-
<link rel="stylesheet" href="../base.css" />
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="../favicon.png" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
-
<style type='text/css'>
|
|
13
|
-
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(../sort-arrow-sprite.png);
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<div class='wrapper'>
|
|
21
|
-
<div class='pad1'>
|
|
22
|
-
<h1><a href="../index.html">All files</a> / <a href="index.html">src</a> apiExpressRouterFactory.ts</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">0% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>0/37</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">100% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>1/1</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">100% </span>
|
|
41
|
-
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>1/1</span>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">0% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>0/37</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<p class="quiet">
|
|
55
|
-
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
-
</p>
|
|
57
|
-
<template id="filterTemplate">
|
|
58
|
-
<div class="quiet">
|
|
59
|
-
Filter:
|
|
60
|
-
<input type="search" id="fileSearch">
|
|
61
|
-
</div>
|
|
62
|
-
</template>
|
|
63
|
-
</div>
|
|
64
|
-
<div class='status-line low'></div>
|
|
65
|
-
<pre><table class="coverage">
|
|
66
|
-
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
67
|
-
<a name='L2'></a><a href='#L2'>2</a>
|
|
68
|
-
<a name='L3'></a><a href='#L3'>3</a>
|
|
69
|
-
<a name='L4'></a><a href='#L4'>4</a>
|
|
70
|
-
<a name='L5'></a><a href='#L5'>5</a>
|
|
71
|
-
<a name='L6'></a><a href='#L6'>6</a>
|
|
72
|
-
<a name='L7'></a><a href='#L7'>7</a>
|
|
73
|
-
<a name='L8'></a><a href='#L8'>8</a>
|
|
74
|
-
<a name='L9'></a><a href='#L9'>9</a>
|
|
75
|
-
<a name='L10'></a><a href='#L10'>10</a>
|
|
76
|
-
<a name='L11'></a><a href='#L11'>11</a>
|
|
77
|
-
<a name='L12'></a><a href='#L12'>12</a>
|
|
78
|
-
<a name='L13'></a><a href='#L13'>13</a>
|
|
79
|
-
<a name='L14'></a><a href='#L14'>14</a>
|
|
80
|
-
<a name='L15'></a><a href='#L15'>15</a>
|
|
81
|
-
<a name='L16'></a><a href='#L16'>16</a>
|
|
82
|
-
<a name='L17'></a><a href='#L17'>17</a>
|
|
83
|
-
<a name='L18'></a><a href='#L18'>18</a>
|
|
84
|
-
<a name='L19'></a><a href='#L19'>19</a>
|
|
85
|
-
<a name='L20'></a><a href='#L20'>20</a>
|
|
86
|
-
<a name='L21'></a><a href='#L21'>21</a>
|
|
87
|
-
<a name='L22'></a><a href='#L22'>22</a>
|
|
88
|
-
<a name='L23'></a><a href='#L23'>23</a>
|
|
89
|
-
<a name='L24'></a><a href='#L24'>24</a>
|
|
90
|
-
<a name='L25'></a><a href='#L25'>25</a>
|
|
91
|
-
<a name='L26'></a><a href='#L26'>26</a>
|
|
92
|
-
<a name='L27'></a><a href='#L27'>27</a>
|
|
93
|
-
<a name='L28'></a><a href='#L28'>28</a>
|
|
94
|
-
<a name='L29'></a><a href='#L29'>29</a>
|
|
95
|
-
<a name='L30'></a><a href='#L30'>30</a>
|
|
96
|
-
<a name='L31'></a><a href='#L31'>31</a>
|
|
97
|
-
<a name='L32'></a><a href='#L32'>32</a>
|
|
98
|
-
<a name='L33'></a><a href='#L33'>33</a>
|
|
99
|
-
<a name='L34'></a><a href='#L34'>34</a>
|
|
100
|
-
<a name='L35'></a><a href='#L35'>35</a>
|
|
101
|
-
<a name='L36'></a><a href='#L36'>36</a>
|
|
102
|
-
<a name='L37'></a><a href='#L37'>37</a>
|
|
103
|
-
<a name='L38'></a><a href='#L38'>38</a>
|
|
104
|
-
<a name='L39'></a><a href='#L39'>39</a>
|
|
105
|
-
<a name='L40'></a><a href='#L40'>40</a>
|
|
106
|
-
<a name='L41'></a><a href='#L41'>41</a>
|
|
107
|
-
<a name='L42'></a><a href='#L42'>42</a>
|
|
108
|
-
<a name='L43'></a><a href='#L43'>43</a>
|
|
109
|
-
<a name='L44'></a><a href='#L44'>44</a>
|
|
110
|
-
<a name='L45'></a><a href='#L45'>45</a>
|
|
111
|
-
<a name='L46'></a><a href='#L46'>46</a>
|
|
112
|
-
<a name='L47'></a><a href='#L47'>47</a>
|
|
113
|
-
<a name='L48'></a><a href='#L48'>48</a>
|
|
114
|
-
<a name='L49'></a><a href='#L49'>49</a>
|
|
115
|
-
<a name='L50'></a><a href='#L50'>50</a>
|
|
116
|
-
<a name='L51'></a><a href='#L51'>51</a>
|
|
117
|
-
<a name='L52'></a><a href='#L52'>52</a>
|
|
118
|
-
<a name='L53'></a><a href='#L53'>53</a>
|
|
119
|
-
<a name='L54'></a><a href='#L54'>54</a>
|
|
120
|
-
<a name='L55'></a><a href='#L55'>55</a>
|
|
121
|
-
<a name='L56'></a><a href='#L56'>56</a>
|
|
122
|
-
<a name='L57'></a><a href='#L57'>57</a>
|
|
123
|
-
<a name='L58'></a><a href='#L58'>58</a>
|
|
124
|
-
<a name='L59'></a><a href='#L59'>59</a>
|
|
125
|
-
<a name='L60'></a><a href='#L60'>60</a>
|
|
126
|
-
<a name='L61'></a><a href='#L61'>61</a>
|
|
127
|
-
<a name='L62'></a><a href='#L62'>62</a>
|
|
128
|
-
<a name='L63'></a><a href='#L63'>63</a>
|
|
129
|
-
<a name='L64'></a><a href='#L64'>64</a>
|
|
130
|
-
<a name='L65'></a><a href='#L65'>65</a>
|
|
131
|
-
<a name='L66'></a><a href='#L66'>66</a>
|
|
132
|
-
<a name='L67'></a><a href='#L67'>67</a>
|
|
133
|
-
<a name='L68'></a><a href='#L68'>68</a>
|
|
134
|
-
<a name='L69'></a><a href='#L69'>69</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
135
|
-
<span class="cline-any cline-neutral"> </span>
|
|
136
|
-
<span class="cline-any cline-neutral"> </span>
|
|
137
|
-
<span class="cline-any cline-neutral"> </span>
|
|
138
|
-
<span class="cline-any cline-neutral"> </span>
|
|
139
|
-
<span class="cline-any cline-neutral"> </span>
|
|
140
|
-
<span class="cline-any cline-neutral"> </span>
|
|
141
|
-
<span class="cline-any cline-neutral"> </span>
|
|
142
|
-
<span class="cline-any cline-neutral"> </span>
|
|
143
|
-
<span class="cline-any cline-neutral"> </span>
|
|
144
|
-
<span class="cline-any cline-neutral"> </span>
|
|
145
|
-
<span class="cline-any cline-neutral"> </span>
|
|
146
|
-
<span class="cline-any cline-neutral"> </span>
|
|
147
|
-
<span class="cline-any cline-neutral"> </span>
|
|
148
|
-
<span class="cline-any cline-neutral"> </span>
|
|
149
|
-
<span class="cline-any cline-no"> </span>
|
|
150
|
-
<span class="cline-any cline-neutral"> </span>
|
|
151
|
-
<span class="cline-any cline-neutral"> </span>
|
|
152
|
-
<span class="cline-any cline-neutral"> </span>
|
|
153
|
-
<span class="cline-any cline-neutral"> </span>
|
|
154
|
-
<span class="cline-any cline-neutral"> </span>
|
|
155
|
-
<span class="cline-any cline-neutral"> </span>
|
|
156
|
-
<span class="cline-any cline-no"> </span>
|
|
157
|
-
<span class="cline-any cline-neutral"> </span>
|
|
158
|
-
<span class="cline-any cline-no"> </span>
|
|
159
|
-
<span class="cline-any cline-no"> </span>
|
|
160
|
-
<span class="cline-any cline-no"> </span>
|
|
161
|
-
<span class="cline-any cline-no"> </span>
|
|
162
|
-
<span class="cline-any cline-no"> </span>
|
|
163
|
-
<span class="cline-any cline-no"> </span>
|
|
164
|
-
<span class="cline-any cline-no"> </span>
|
|
165
|
-
<span class="cline-any cline-neutral"> </span>
|
|
166
|
-
<span class="cline-any cline-no"> </span>
|
|
167
|
-
<span class="cline-any cline-neutral"> </span>
|
|
168
|
-
<span class="cline-any cline-neutral"> </span>
|
|
169
|
-
<span class="cline-any cline-neutral"> </span>
|
|
170
|
-
<span class="cline-any cline-neutral"> </span>
|
|
171
|
-
<span class="cline-any cline-no"> </span>
|
|
172
|
-
<span class="cline-any cline-neutral"> </span>
|
|
173
|
-
<span class="cline-any cline-no"> </span>
|
|
174
|
-
<span class="cline-any cline-no"> </span>
|
|
175
|
-
<span class="cline-any cline-neutral"> </span>
|
|
176
|
-
<span class="cline-any cline-no"> </span>
|
|
177
|
-
<span class="cline-any cline-no"> </span>
|
|
178
|
-
<span class="cline-any cline-no"> </span>
|
|
179
|
-
<span class="cline-any cline-no"> </span>
|
|
180
|
-
<span class="cline-any cline-no"> </span>
|
|
181
|
-
<span class="cline-any cline-no"> </span>
|
|
182
|
-
<span class="cline-any cline-no"> </span>
|
|
183
|
-
<span class="cline-any cline-no"> </span>
|
|
184
|
-
<span class="cline-any cline-no"> </span>
|
|
185
|
-
<span class="cline-any cline-no"> </span>
|
|
186
|
-
<span class="cline-any cline-no"> </span>
|
|
187
|
-
<span class="cline-any cline-no"> </span>
|
|
188
|
-
<span class="cline-any cline-no"> </span>
|
|
189
|
-
<span class="cline-any cline-no"> </span>
|
|
190
|
-
<span class="cline-any cline-no"> </span>
|
|
191
|
-
<span class="cline-any cline-no"> </span>
|
|
192
|
-
<span class="cline-any cline-no"> </span>
|
|
193
|
-
<span class="cline-any cline-no"> </span>
|
|
194
|
-
<span class="cline-any cline-no"> </span>
|
|
195
|
-
<span class="cline-any cline-no"> </span>
|
|
196
|
-
<span class="cline-any cline-no"> </span>
|
|
197
|
-
<span class="cline-any cline-no"> </span>
|
|
198
|
-
<span class="cline-any cline-no"> </span>
|
|
199
|
-
<span class="cline-any cline-no"> </span>
|
|
200
|
-
<span class="cline-any cline-neutral"> </span>
|
|
201
|
-
<span class="cline-any cline-neutral"> </span>
|
|
202
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">// Copyright 2021-2025 Prosopo (UK) Ltd.
|
|
203
|
-
//
|
|
204
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
205
|
-
// you may not use this file except in compliance with the License.
|
|
206
|
-
// You may obtain a copy of the License at
|
|
207
|
-
//
|
|
208
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
209
|
-
//
|
|
210
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
211
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
212
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
213
|
-
// See the License for the specific language governing permissions and
|
|
214
|
-
// limitations under the License.
|
|
215
|
-
|
|
216
|
-
import type { ApiRoute, ApiRoutesProvider } from "@prosopo/api-route";
|
|
217
|
-
<span class="cstat-no" title="statement not covered" >import {</span>
|
|
218
|
-
type NextFunction,
|
|
219
|
-
type Request,
|
|
220
|
-
type Response,
|
|
221
|
-
Router,
|
|
222
|
-
} from "express";
|
|
223
|
-
import type { ApiExpressEndpointAdapter } from "./endpointAdapter/apiExpressEndpointAdapter.js";
|
|
224
|
-
<span class="cstat-no" title="statement not covered" >import { handleErrors } from "./errorHandler.js";</span>
|
|
225
|
-
|
|
226
|
-
<span class="cstat-no" title="statement not covered" >class ApiExpressRouterFactory {</span>
|
|
227
|
-
<span class="cstat-no" title="statement not covered" > public createRouter(</span>
|
|
228
|
-
<span class="cstat-no" title="statement not covered" > routersProvider: ApiRoutesProvider,</span>
|
|
229
|
-
<span class="cstat-no" title="statement not covered" > apiEndpointAdapter: ApiExpressEndpointAdapter,</span>
|
|
230
|
-
<span class="cstat-no" title="statement not covered" > ): Router {</span>
|
|
231
|
-
<span class="cstat-no" title="statement not covered" > const router = Router();</span>
|
|
232
|
-
<span class="cstat-no" title="statement not covered" > const apiRoutes = routersProvider.getRoutes();</span>
|
|
233
|
-
|
|
234
|
-
<span class="cstat-no" title="statement not covered" > this.registerRoutes(router, apiRoutes, apiEndpointAdapter);</span>
|
|
235
|
-
|
|
236
|
-
// Your error handler should always be at the end of your application stack. Apparently it means not only after all
|
|
237
|
-
// app.use() but also after all your app.get() and app.post() calls.
|
|
238
|
-
// https://stackoverflow.com/a/62358794/1178971
|
|
239
|
-
<span class="cstat-no" title="statement not covered" > router.use(handleErrors);</span>
|
|
240
|
-
|
|
241
|
-
<span class="cstat-no" title="statement not covered" > return router;</span>
|
|
242
|
-
<span class="cstat-no" title="statement not covered" > }</span>
|
|
243
|
-
|
|
244
|
-
<span class="cstat-no" title="statement not covered" > protected registerRoutes(</span>
|
|
245
|
-
<span class="cstat-no" title="statement not covered" > router: Router,</span>
|
|
246
|
-
<span class="cstat-no" title="statement not covered" > routes: ApiRoute[],</span>
|
|
247
|
-
<span class="cstat-no" title="statement not covered" > apiEndpointAdapter: ApiExpressEndpointAdapter,</span>
|
|
248
|
-
<span class="cstat-no" title="statement not covered" > ): void {</span>
|
|
249
|
-
<span class="cstat-no" title="statement not covered" > for (const route of routes) {</span>
|
|
250
|
-
<span class="cstat-no" title="statement not covered" > router.post(</span>
|
|
251
|
-
<span class="cstat-no" title="statement not covered" > route.path,</span>
|
|
252
|
-
<span class="cstat-no" title="statement not covered" > async (</span>
|
|
253
|
-
<span class="cstat-no" title="statement not covered" > request: Request,</span>
|
|
254
|
-
<span class="cstat-no" title="statement not covered" > response: Response,</span>
|
|
255
|
-
<span class="cstat-no" title="statement not covered" > next: NextFunction,</span>
|
|
256
|
-
<span class="cstat-no" title="statement not covered" > ): Promise<void> => {</span>
|
|
257
|
-
<span class="cstat-no" title="statement not covered" > return await apiEndpointAdapter.handleRequest(</span>
|
|
258
|
-
<span class="cstat-no" title="statement not covered" > route.endpoint,</span>
|
|
259
|
-
<span class="cstat-no" title="statement not covered" > request,</span>
|
|
260
|
-
<span class="cstat-no" title="statement not covered" > response,</span>
|
|
261
|
-
<span class="cstat-no" title="statement not covered" > next,</span>
|
|
262
|
-
<span class="cstat-no" title="statement not covered" > );</span>
|
|
263
|
-
<span class="cstat-no" title="statement not covered" > },</span>
|
|
264
|
-
<span class="cstat-no" title="statement not covered" > );</span>
|
|
265
|
-
<span class="cstat-no" title="statement not covered" > }</span>
|
|
266
|
-
<span class="cstat-no" title="statement not covered" > }</span>
|
|
267
|
-
<span class="cstat-no" title="statement not covered" >}</span>
|
|
268
|
-
|
|
269
|
-
export { ApiExpressRouterFactory };
|
|
270
|
-
</pre></td></tr></table></pre>
|
|
271
|
-
|
|
272
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
273
|
-
</div><!-- /wrapper -->
|
|
274
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
275
|
-
Code coverage generated by
|
|
276
|
-
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
277
|
-
at 2025-09-29T09:25:03.023Z
|
|
278
|
-
</div>
|
|
279
|
-
<script src="../prettify.js"></script>
|
|
280
|
-
<script>
|
|
281
|
-
window.onload = function () {
|
|
282
|
-
prettyPrint();
|
|
283
|
-
};
|
|
284
|
-
</script>
|
|
285
|
-
<script src="../sorter.js"></script>
|
|
286
|
-
<script src="../block-navigation.js"></script>
|
|
287
|
-
</body>
|
|
288
|
-
</html>
|
|
289
|
-
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for src/endpointAdapter/apiExpressDefaultEndpointAdapter.ts</title>
|
|
7
|
-
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
|
-
<link rel="stylesheet" href="../../base.css" />
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
-
<style type='text/css'>
|
|
13
|
-
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(../../sort-arrow-sprite.png);
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<div class='wrapper'>
|
|
21
|
-
<div class='pad1'>
|
|
22
|
-
<h1><a href="../../index.html">All files</a> / <a href="index.html">src/endpointAdapter</a> apiExpressDefaultEndpointAdapter.ts</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">0% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>0/36</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">100% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>1/1</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">100% </span>
|
|
41
|
-
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>1/1</span>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">0% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>0/36</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<p class="quiet">
|
|
55
|
-
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
-
</p>
|
|
57
|
-
<template id="filterTemplate">
|
|
58
|
-
<div class="quiet">
|
|
59
|
-
Filter:
|
|
60
|
-
<input type="search" id="fileSearch">
|
|
61
|
-
</div>
|
|
62
|
-
</template>
|
|
63
|
-
</div>
|
|
64
|
-
<div class='status-line low'></div>
|
|
65
|
-
<pre><table class="coverage">
|
|
66
|
-
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
67
|
-
<a name='L2'></a><a href='#L2'>2</a>
|
|
68
|
-
<a name='L3'></a><a href='#L3'>3</a>
|
|
69
|
-
<a name='L4'></a><a href='#L4'>4</a>
|
|
70
|
-
<a name='L5'></a><a href='#L5'>5</a>
|
|
71
|
-
<a name='L6'></a><a href='#L6'>6</a>
|
|
72
|
-
<a name='L7'></a><a href='#L7'>7</a>
|
|
73
|
-
<a name='L8'></a><a href='#L8'>8</a>
|
|
74
|
-
<a name='L9'></a><a href='#L9'>9</a>
|
|
75
|
-
<a name='L10'></a><a href='#L10'>10</a>
|
|
76
|
-
<a name='L11'></a><a href='#L11'>11</a>
|
|
77
|
-
<a name='L12'></a><a href='#L12'>12</a>
|
|
78
|
-
<a name='L13'></a><a href='#L13'>13</a>
|
|
79
|
-
<a name='L14'></a><a href='#L14'>14</a>
|
|
80
|
-
<a name='L15'></a><a href='#L15'>15</a>
|
|
81
|
-
<a name='L16'></a><a href='#L16'>16</a>
|
|
82
|
-
<a name='L17'></a><a href='#L17'>17</a>
|
|
83
|
-
<a name='L18'></a><a href='#L18'>18</a>
|
|
84
|
-
<a name='L19'></a><a href='#L19'>19</a>
|
|
85
|
-
<a name='L20'></a><a href='#L20'>20</a>
|
|
86
|
-
<a name='L21'></a><a href='#L21'>21</a>
|
|
87
|
-
<a name='L22'></a><a href='#L22'>22</a>
|
|
88
|
-
<a name='L23'></a><a href='#L23'>23</a>
|
|
89
|
-
<a name='L24'></a><a href='#L24'>24</a>
|
|
90
|
-
<a name='L25'></a><a href='#L25'>25</a>
|
|
91
|
-
<a name='L26'></a><a href='#L26'>26</a>
|
|
92
|
-
<a name='L27'></a><a href='#L27'>27</a>
|
|
93
|
-
<a name='L28'></a><a href='#L28'>28</a>
|
|
94
|
-
<a name='L29'></a><a href='#L29'>29</a>
|
|
95
|
-
<a name='L30'></a><a href='#L30'>30</a>
|
|
96
|
-
<a name='L31'></a><a href='#L31'>31</a>
|
|
97
|
-
<a name='L32'></a><a href='#L32'>32</a>
|
|
98
|
-
<a name='L33'></a><a href='#L33'>33</a>
|
|
99
|
-
<a name='L34'></a><a href='#L34'>34</a>
|
|
100
|
-
<a name='L35'></a><a href='#L35'>35</a>
|
|
101
|
-
<a name='L36'></a><a href='#L36'>36</a>
|
|
102
|
-
<a name='L37'></a><a href='#L37'>37</a>
|
|
103
|
-
<a name='L38'></a><a href='#L38'>38</a>
|
|
104
|
-
<a name='L39'></a><a href='#L39'>39</a>
|
|
105
|
-
<a name='L40'></a><a href='#L40'>40</a>
|
|
106
|
-
<a name='L41'></a><a href='#L41'>41</a>
|
|
107
|
-
<a name='L42'></a><a href='#L42'>42</a>
|
|
108
|
-
<a name='L43'></a><a href='#L43'>43</a>
|
|
109
|
-
<a name='L44'></a><a href='#L44'>44</a>
|
|
110
|
-
<a name='L45'></a><a href='#L45'>45</a>
|
|
111
|
-
<a name='L46'></a><a href='#L46'>46</a>
|
|
112
|
-
<a name='L47'></a><a href='#L47'>47</a>
|
|
113
|
-
<a name='L48'></a><a href='#L48'>48</a>
|
|
114
|
-
<a name='L49'></a><a href='#L49'>49</a>
|
|
115
|
-
<a name='L50'></a><a href='#L50'>50</a>
|
|
116
|
-
<a name='L51'></a><a href='#L51'>51</a>
|
|
117
|
-
<a name='L52'></a><a href='#L52'>52</a>
|
|
118
|
-
<a name='L53'></a><a href='#L53'>53</a>
|
|
119
|
-
<a name='L54'></a><a href='#L54'>54</a>
|
|
120
|
-
<a name='L55'></a><a href='#L55'>55</a>
|
|
121
|
-
<a name='L56'></a><a href='#L56'>56</a>
|
|
122
|
-
<a name='L57'></a><a href='#L57'>57</a>
|
|
123
|
-
<a name='L58'></a><a href='#L58'>58</a>
|
|
124
|
-
<a name='L59'></a><a href='#L59'>59</a>
|
|
125
|
-
<a name='L60'></a><a href='#L60'>60</a>
|
|
126
|
-
<a name='L61'></a><a href='#L61'>61</a>
|
|
127
|
-
<a name='L62'></a><a href='#L62'>62</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
128
|
-
<span class="cline-any cline-neutral"> </span>
|
|
129
|
-
<span class="cline-any cline-neutral"> </span>
|
|
130
|
-
<span class="cline-any cline-neutral"> </span>
|
|
131
|
-
<span class="cline-any cline-neutral"> </span>
|
|
132
|
-
<span class="cline-any cline-neutral"> </span>
|
|
133
|
-
<span class="cline-any cline-neutral"> </span>
|
|
134
|
-
<span class="cline-any cline-neutral"> </span>
|
|
135
|
-
<span class="cline-any cline-neutral"> </span>
|
|
136
|
-
<span class="cline-any cline-neutral"> </span>
|
|
137
|
-
<span class="cline-any cline-neutral"> </span>
|
|
138
|
-
<span class="cline-any cline-neutral"> </span>
|
|
139
|
-
<span class="cline-any cline-neutral"> </span>
|
|
140
|
-
<span class="cline-any cline-neutral"> </span>
|
|
141
|
-
<span class="cline-any cline-neutral"> </span>
|
|
142
|
-
<span class="cline-any cline-no"> </span>
|
|
143
|
-
<span class="cline-any cline-neutral"> </span>
|
|
144
|
-
<span class="cline-any cline-neutral"> </span>
|
|
145
|
-
<span class="cline-any cline-neutral"> </span>
|
|
146
|
-
<span class="cline-any cline-neutral"> </span>
|
|
147
|
-
<span class="cline-any cline-no"> </span>
|
|
148
|
-
<span class="cline-any cline-no"> </span>
|
|
149
|
-
<span class="cline-any cline-no"> </span>
|
|
150
|
-
<span class="cline-any cline-no"> </span>
|
|
151
|
-
<span class="cline-any cline-no"> </span>
|
|
152
|
-
<span class="cline-any cline-neutral"> </span>
|
|
153
|
-
<span class="cline-any cline-no"> </span>
|
|
154
|
-
<span class="cline-any cline-no"> </span>
|
|
155
|
-
<span class="cline-any cline-no"> </span>
|
|
156
|
-
<span class="cline-any cline-no"> </span>
|
|
157
|
-
<span class="cline-any cline-no"> </span>
|
|
158
|
-
<span class="cline-any cline-no"> </span>
|
|
159
|
-
<span class="cline-any cline-no"> </span>
|
|
160
|
-
<span class="cline-any cline-no"> </span>
|
|
161
|
-
<span class="cline-any cline-no"> </span>
|
|
162
|
-
<span class="cline-any cline-no"> </span>
|
|
163
|
-
<span class="cline-any cline-no"> </span>
|
|
164
|
-
<span class="cline-any cline-no"> </span>
|
|
165
|
-
<span class="cline-any cline-no"> </span>
|
|
166
|
-
<span class="cline-any cline-no"> </span>
|
|
167
|
-
<span class="cline-any cline-no"> </span>
|
|
168
|
-
<span class="cline-any cline-no"> </span>
|
|
169
|
-
<span class="cline-any cline-neutral"> </span>
|
|
170
|
-
<span class="cline-any cline-no"> </span>
|
|
171
|
-
<span class="cline-any cline-no"> </span>
|
|
172
|
-
<span class="cline-any cline-no"> </span>
|
|
173
|
-
<span class="cline-any cline-no"> </span>
|
|
174
|
-
<span class="cline-any cline-no"> </span>
|
|
175
|
-
<span class="cline-any cline-neutral"> </span>
|
|
176
|
-
<span class="cline-any cline-no"> </span>
|
|
177
|
-
<span class="cline-any cline-no"> </span>
|
|
178
|
-
<span class="cline-any cline-no"> </span>
|
|
179
|
-
<span class="cline-any cline-no"> </span>
|
|
180
|
-
<span class="cline-any cline-no"> </span>
|
|
181
|
-
<span class="cline-any cline-neutral"> </span>
|
|
182
|
-
<span class="cline-any cline-no"> </span>
|
|
183
|
-
<span class="cline-any cline-no"> </span>
|
|
184
|
-
<span class="cline-any cline-no"> </span>
|
|
185
|
-
<span class="cline-any cline-no"> </span>
|
|
186
|
-
<span class="cline-any cline-neutral"> </span>
|
|
187
|
-
<span class="cline-any cline-neutral"> </span>
|
|
188
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">// Copyright 2021-2025 Prosopo (UK) Ltd.
|
|
189
|
-
//
|
|
190
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
191
|
-
// you may not use this file except in compliance with the License.
|
|
192
|
-
// You may obtain a copy of the License at
|
|
193
|
-
//
|
|
194
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
195
|
-
//
|
|
196
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
197
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
198
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
199
|
-
// See the License for the specific language governing permissions and
|
|
200
|
-
// limitations under the License.
|
|
201
|
-
|
|
202
|
-
import type { ApiEndpoint } from "@prosopo/api-route";
|
|
203
|
-
<span class="cstat-no" title="statement not covered" >import { type LogLevel, ProsopoApiError } from "@prosopo/common";</span>
|
|
204
|
-
import type { NextFunction, Request, Response } from "express";
|
|
205
|
-
import type { ZodType } from "zod";
|
|
206
|
-
import type { ApiExpressEndpointAdapter } from "./apiExpressEndpointAdapter.js";
|
|
207
|
-
|
|
208
|
-
<span class="cstat-no" title="statement not covered" >class ApiExpressDefaultEndpointAdapter implements ApiExpressEndpointAdapter {</span>
|
|
209
|
-
<span class="cstat-no" title="statement not covered" > public constructor(</span>
|
|
210
|
-
<span class="cstat-no" title="statement not covered" > private readonly logLevel: LogLevel,</span>
|
|
211
|
-
<span class="cstat-no" title="statement not covered" > private readonly errorStatusCode: number,</span>
|
|
212
|
-
<span class="cstat-no" title="statement not covered" > ) {}</span>
|
|
213
|
-
|
|
214
|
-
<span class="cstat-no" title="statement not covered" > public async handleRequest(</span>
|
|
215
|
-
<span class="cstat-no" title="statement not covered" > endpoint: ApiEndpoint<ZodType | undefined>,</span>
|
|
216
|
-
<span class="cstat-no" title="statement not covered" > request: Request,</span>
|
|
217
|
-
<span class="cstat-no" title="statement not covered" > response: Response,</span>
|
|
218
|
-
<span class="cstat-no" title="statement not covered" > next: NextFunction,</span>
|
|
219
|
-
<span class="cstat-no" title="statement not covered" > ): Promise<void> {</span>
|
|
220
|
-
<span class="cstat-no" title="statement not covered" > let args: unknown;</span>
|
|
221
|
-
<span class="cstat-no" title="statement not covered" > try {</span>
|
|
222
|
-
<span class="cstat-no" title="statement not covered" > args = endpoint.getRequestArgsSchema()?.parse(request.body);</span>
|
|
223
|
-
<span class="cstat-no" title="statement not covered" > } catch (error) {</span>
|
|
224
|
-
<span class="cstat-no" title="statement not covered" > return next(</span>
|
|
225
|
-
<span class="cstat-no" title="statement not covered" > new ProsopoApiError("API.PARSE_ERROR", {</span>
|
|
226
|
-
<span class="cstat-no" title="statement not covered" > context: { code: 400, error: error },</span>
|
|
227
|
-
<span class="cstat-no" title="statement not covered" > }),</span>
|
|
228
|
-
<span class="cstat-no" title="statement not covered" > );</span>
|
|
229
|
-
<span class="cstat-no" title="statement not covered" > }</span>
|
|
230
|
-
|
|
231
|
-
<span class="cstat-no" title="statement not covered" > try {</span>
|
|
232
|
-
<span class="cstat-no" title="statement not covered" > const apiEndpointResponse = await endpoint.processRequest(</span>
|
|
233
|
-
<span class="cstat-no" title="statement not covered" > args,</span>
|
|
234
|
-
<span class="cstat-no" title="statement not covered" > request.logger,</span>
|
|
235
|
-
<span class="cstat-no" title="statement not covered" > );</span>
|
|
236
|
-
|
|
237
|
-
<span class="cstat-no" title="statement not covered" > response.json(apiEndpointResponse);</span>
|
|
238
|
-
<span class="cstat-no" title="statement not covered" > } catch (error) {</span>
|
|
239
|
-
<span class="cstat-no" title="statement not covered" > request.logger.error(() => ({</span>
|
|
240
|
-
<span class="cstat-no" title="statement not covered" > err: error,</span>
|
|
241
|
-
<span class="cstat-no" title="statement not covered" > }));</span>
|
|
242
|
-
|
|
243
|
-
<span class="cstat-no" title="statement not covered" > response.status(500).send("An internal server error occurred.");</span>
|
|
244
|
-
<span class="cstat-no" title="statement not covered" > }</span>
|
|
245
|
-
<span class="cstat-no" title="statement not covered" > }</span>
|
|
246
|
-
<span class="cstat-no" title="statement not covered" >}</span>
|
|
247
|
-
|
|
248
|
-
export { ApiExpressDefaultEndpointAdapter };
|
|
249
|
-
</pre></td></tr></table></pre>
|
|
250
|
-
|
|
251
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
252
|
-
</div><!-- /wrapper -->
|
|
253
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
254
|
-
Code coverage generated by
|
|
255
|
-
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
256
|
-
at 2025-09-29T09:25:03.023Z
|
|
257
|
-
</div>
|
|
258
|
-
<script src="../../prettify.js"></script>
|
|
259
|
-
<script>
|
|
260
|
-
window.onload = function () {
|
|
261
|
-
prettyPrint();
|
|
262
|
-
};
|
|
263
|
-
</script>
|
|
264
|
-
<script src="../../sorter.js"></script>
|
|
265
|
-
<script src="../../block-navigation.js"></script>
|
|
266
|
-
</body>
|
|
267
|
-
</html>
|
|
268
|
-
|