@furystack/rest-service 6.2.23 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/esm/actions/error-action.js +25 -0
  2. package/esm/actions/error-action.js.map +1 -0
  3. package/esm/actions/get-current-user.js +12 -0
  4. package/esm/actions/get-current-user.js.map +1 -0
  5. package/esm/actions/index.js +7 -0
  6. package/esm/actions/index.js.map +1 -0
  7. package/esm/actions/is-authenticated.js +13 -0
  8. package/esm/actions/is-authenticated.js.map +1 -0
  9. package/esm/actions/login.js +22 -0
  10. package/esm/actions/login.js.map +1 -0
  11. package/esm/actions/logout.js +15 -0
  12. package/esm/actions/logout.js.map +1 -0
  13. package/esm/actions/not-found-action.js +10 -0
  14. package/esm/actions/not-found-action.js.map +1 -0
  15. package/{dist → esm}/api-manager.js +29 -32
  16. package/esm/api-manager.js.map +1 -0
  17. package/esm/authenticate.js +16 -0
  18. package/esm/authenticate.js.map +1 -0
  19. package/esm/authorize.js +19 -0
  20. package/esm/authorize.js.map +1 -0
  21. package/esm/endpoint-generators/create-delete-endpoint.js +20 -0
  22. package/esm/endpoint-generators/create-delete-endpoint.js.map +1 -0
  23. package/esm/endpoint-generators/create-get-collection-endpoint.js +22 -0
  24. package/esm/endpoint-generators/create-get-collection-endpoint.js.map +1 -0
  25. package/esm/endpoint-generators/create-get-entity-endpoint.js +25 -0
  26. package/esm/endpoint-generators/create-get-entity-endpoint.js.map +1 -0
  27. package/esm/endpoint-generators/create-patch-endpoint.js +22 -0
  28. package/esm/endpoint-generators/create-patch-endpoint.js.map +1 -0
  29. package/esm/endpoint-generators/create-post-endpoint.js +25 -0
  30. package/esm/endpoint-generators/create-post-endpoint.js.map +1 -0
  31. package/esm/endpoint-generators/index.js +6 -0
  32. package/esm/endpoint-generators/index.js.map +1 -0
  33. package/esm/endpoint-generators/utils.js +23 -0
  34. package/esm/endpoint-generators/utils.js.map +1 -0
  35. package/esm/helpers.js +28 -0
  36. package/esm/helpers.js.map +1 -0
  37. package/{dist → esm}/http-authentication-settings.js +8 -11
  38. package/esm/http-authentication-settings.js.map +1 -0
  39. package/{dist → esm}/http-user-context.js +19 -25
  40. package/esm/http-user-context.js.map +1 -0
  41. package/esm/incoming-message-extensions.js +11 -0
  42. package/esm/incoming-message-extensions.js.map +1 -0
  43. package/esm/index.js +19 -0
  44. package/esm/index.js.map +1 -0
  45. package/{dist → esm}/mime-types.js +5 -12
  46. package/esm/mime-types.js.map +1 -0
  47. package/esm/models/cors-options.js +2 -0
  48. package/esm/models/default-session.js +6 -0
  49. package/{dist → esm}/models/default-session.js.map +1 -1
  50. package/esm/models/index.js +3 -0
  51. package/esm/models/index.js.map +1 -0
  52. package/esm/request-action-implementation.js +34 -0
  53. package/esm/request-action-implementation.js.map +1 -0
  54. package/esm/schema-validator/index.js +3 -0
  55. package/esm/schema-validator/index.js.map +1 -0
  56. package/esm/schema-validator/schema-validation-error.js +11 -0
  57. package/esm/schema-validator/schema-validation-error.js.map +1 -0
  58. package/{dist → esm}/schema-validator/schema-validator.js +7 -14
  59. package/esm/schema-validator/schema-validator.js.map +1 -0
  60. package/{dist → esm}/schema-validator/validate-examples.js +1 -4
  61. package/esm/schema-validator/validate-examples.js.map +1 -0
  62. package/{dist → esm}/server-manager.js +7 -13
  63. package/esm/server-manager.js.map +1 -0
  64. package/esm/server-response-extensions.js +12 -0
  65. package/esm/server-response-extensions.js.map +1 -0
  66. package/{dist → esm}/static-server-manager.js +16 -19
  67. package/esm/static-server-manager.js.map +1 -0
  68. package/{dist → esm}/utils.js +3 -8
  69. package/esm/utils.js.map +1 -0
  70. package/esm/validate.integration.schema.js +2 -0
  71. package/{dist → esm}/validate.js +3 -7
  72. package/esm/validate.js.map +1 -0
  73. package/package.json +30 -13
  74. package/src/actions/error-action.spec.ts +1 -0
  75. package/src/actions/get-current-user.spec.ts +1 -0
  76. package/src/actions/get-current-user.ts +0 -1
  77. package/src/actions/is-authenticated.spec.ts +1 -0
  78. package/src/actions/is-authenticated.ts +0 -1
  79. package/src/actions/login-action.spec.ts +3 -2
  80. package/src/actions/logout-action.spec.ts +2 -1
  81. package/src/actions/logout.ts +0 -1
  82. package/src/actions/not-found-action.spec.ts +1 -0
  83. package/src/add-cors-header.spec.ts +7 -6
  84. package/src/authenticate.spec.ts +7 -6
  85. package/src/authorize.spec.ts +7 -6
  86. package/src/endpoint-generators/create-delete-endpoint.spec.ts +1 -0
  87. package/src/endpoint-generators/create-delete-endpoint.ts +0 -1
  88. package/src/endpoint-generators/create-get-collection-endpoint.spec.ts +1 -0
  89. package/src/endpoint-generators/create-get-collection-endpoint.ts +0 -1
  90. package/src/endpoint-generators/create-get-entity-endpoint.spec.ts +1 -0
  91. package/src/endpoint-generators/create-get-entity-endpoint.ts +0 -1
  92. package/src/endpoint-generators/create-patch-endpoint.spec.ts +1 -0
  93. package/src/endpoint-generators/create-patch-endpoint.ts +0 -1
  94. package/src/endpoint-generators/create-post-endpoint.spec.ts +1 -0
  95. package/src/endpoint-generators/create-post-endpoint.ts +0 -1
  96. package/src/helpers.spec.ts +1 -0
  97. package/src/helpers.ts +2 -6
  98. package/src/http-user-context.spec.ts +15 -14
  99. package/src/http-user-context.ts +0 -3
  100. package/src/incoming-message-extensions.spec.ts +1 -0
  101. package/src/mime-types.spec.ts +1 -0
  102. package/src/rest-service.integration.spec.ts +1 -0
  103. package/src/rest.integration.test.ts +1 -0
  104. package/src/schema-validator/schema-validator.test.ts +1 -0
  105. package/src/server-manager.ts +2 -2
  106. package/src/server-response-extensions.spec.ts +23 -18
  107. package/src/static-server-manager.spec.ts +2 -2
  108. package/src/utils.ts +0 -2
  109. package/src/validate.integration.spec.ts +1 -0
  110. package/types/actions/get-current-user.d.ts +0 -1
  111. package/types/actions/get-current-user.d.ts.map +1 -1
  112. package/types/actions/is-authenticated.d.ts +0 -1
  113. package/types/actions/is-authenticated.d.ts.map +1 -1
  114. package/types/actions/logout.d.ts +0 -1
  115. package/types/actions/logout.d.ts.map +1 -1
  116. package/types/endpoint-generators/create-delete-endpoint.d.ts +0 -1
  117. package/types/endpoint-generators/create-delete-endpoint.d.ts.map +1 -1
  118. package/types/endpoint-generators/create-get-collection-endpoint.d.ts +0 -1
  119. package/types/endpoint-generators/create-get-collection-endpoint.d.ts.map +1 -1
  120. package/types/endpoint-generators/create-get-entity-endpoint.d.ts +0 -1
  121. package/types/endpoint-generators/create-get-entity-endpoint.d.ts.map +1 -1
  122. package/types/endpoint-generators/create-patch-endpoint.d.ts +0 -1
  123. package/types/endpoint-generators/create-patch-endpoint.d.ts.map +1 -1
  124. package/types/endpoint-generators/create-post-endpoint.d.ts +0 -1
  125. package/types/endpoint-generators/create-post-endpoint.d.ts.map +1 -1
  126. package/types/helpers.d.ts +2 -4
  127. package/types/helpers.d.ts.map +1 -1
  128. package/types/http-user-context.d.ts +0 -3
  129. package/types/http-user-context.d.ts.map +1 -1
  130. package/types/server-manager.d.ts.map +1 -1
  131. package/types/utils.d.ts +0 -2
  132. package/types/utils.d.ts.map +1 -1
  133. package/dist/actions/error-action.js +0 -29
  134. package/dist/actions/error-action.js.map +0 -1
  135. package/dist/actions/error-action.spec.js +0 -48
  136. package/dist/actions/error-action.spec.js.map +0 -1
  137. package/dist/actions/get-current-user.js +0 -16
  138. package/dist/actions/get-current-user.js.map +0 -1
  139. package/dist/actions/get-current-user.spec.js +0 -20
  140. package/dist/actions/get-current-user.spec.js.map +0 -1
  141. package/dist/actions/index.js +0 -23
  142. package/dist/actions/index.js.map +0 -1
  143. package/dist/actions/is-authenticated.js +0 -18
  144. package/dist/actions/is-authenticated.js.map +0 -1
  145. package/dist/actions/is-authenticated.spec.js +0 -19
  146. package/dist/actions/is-authenticated.spec.js.map +0 -1
  147. package/dist/actions/login-action.spec.js +0 -35
  148. package/dist/actions/login-action.spec.js.map +0 -1
  149. package/dist/actions/login.js +0 -26
  150. package/dist/actions/login.js.map +0 -1
  151. package/dist/actions/logout-action.spec.js +0 -23
  152. package/dist/actions/logout-action.spec.js.map +0 -1
  153. package/dist/actions/logout.js +0 -20
  154. package/dist/actions/logout.js.map +0 -1
  155. package/dist/actions/not-found-action.js +0 -14
  156. package/dist/actions/not-found-action.js.map +0 -1
  157. package/dist/actions/not-found-action.spec.js +0 -17
  158. package/dist/actions/not-found-action.spec.js.map +0 -1
  159. package/dist/add-cors-header.spec.js +0 -99
  160. package/dist/add-cors-header.spec.js.map +0 -1
  161. package/dist/api-manager.js.map +0 -1
  162. package/dist/authenticate.js +0 -20
  163. package/dist/authenticate.js.map +0 -1
  164. package/dist/authenticate.spec.js +0 -59
  165. package/dist/authenticate.spec.js.map +0 -1
  166. package/dist/authorize.js +0 -23
  167. package/dist/authorize.js.map +0 -1
  168. package/dist/authorize.spec.js +0 -55
  169. package/dist/authorize.spec.js.map +0 -1
  170. package/dist/endpoint-generators/create-delete-endpoint.js +0 -25
  171. package/dist/endpoint-generators/create-delete-endpoint.js.map +0 -1
  172. package/dist/endpoint-generators/create-delete-endpoint.spec.js +0 -35
  173. package/dist/endpoint-generators/create-delete-endpoint.spec.js.map +0 -1
  174. package/dist/endpoint-generators/create-get-collection-endpoint.js +0 -27
  175. package/dist/endpoint-generators/create-get-collection-endpoint.js.map +0 -1
  176. package/dist/endpoint-generators/create-get-collection-endpoint.spec.js +0 -157
  177. package/dist/endpoint-generators/create-get-collection-endpoint.spec.js.map +0 -1
  178. package/dist/endpoint-generators/create-get-entity-endpoint.js +0 -30
  179. package/dist/endpoint-generators/create-get-entity-endpoint.js.map +0 -1
  180. package/dist/endpoint-generators/create-get-entity-endpoint.spec.js +0 -75
  181. package/dist/endpoint-generators/create-get-entity-endpoint.spec.js.map +0 -1
  182. package/dist/endpoint-generators/create-patch-endpoint.js +0 -27
  183. package/dist/endpoint-generators/create-patch-endpoint.js.map +0 -1
  184. package/dist/endpoint-generators/create-patch-endpoint.spec.js +0 -38
  185. package/dist/endpoint-generators/create-patch-endpoint.spec.js.map +0 -1
  186. package/dist/endpoint-generators/create-post-endpoint.js +0 -30
  187. package/dist/endpoint-generators/create-post-endpoint.js.map +0 -1
  188. package/dist/endpoint-generators/create-post-endpoint.spec.js +0 -36
  189. package/dist/endpoint-generators/create-post-endpoint.spec.js.map +0 -1
  190. package/dist/endpoint-generators/index.js +0 -22
  191. package/dist/endpoint-generators/index.js.map +0 -1
  192. package/dist/endpoint-generators/utils.js +0 -28
  193. package/dist/endpoint-generators/utils.js.map +0 -1
  194. package/dist/helpers.js +0 -39
  195. package/dist/helpers.js.map +0 -1
  196. package/dist/helpers.spec.js +0 -35
  197. package/dist/helpers.spec.js.map +0 -1
  198. package/dist/http-authentication-settings.js.map +0 -1
  199. package/dist/http-user-context.js.map +0 -1
  200. package/dist/http-user-context.spec.js +0 -272
  201. package/dist/http-user-context.spec.js.map +0 -1
  202. package/dist/incoming-message-extensions.js +0 -16
  203. package/dist/incoming-message-extensions.js.map +0 -1
  204. package/dist/incoming-message-extensions.spec.js +0 -39
  205. package/dist/incoming-message-extensions.spec.js.map +0 -1
  206. package/dist/index.js +0 -35
  207. package/dist/index.js.map +0 -1
  208. package/dist/mime-types.js.map +0 -1
  209. package/dist/mime-types.spec.js +0 -15
  210. package/dist/mime-types.spec.js.map +0 -1
  211. package/dist/models/cors-options.js +0 -3
  212. package/dist/models/default-session.js +0 -10
  213. package/dist/models/index.js +0 -19
  214. package/dist/models/index.js.map +0 -1
  215. package/dist/request-action-implementation.js +0 -42
  216. package/dist/request-action-implementation.js.map +0 -1
  217. package/dist/rest-service.integration.spec.js +0 -143
  218. package/dist/rest-service.integration.spec.js.map +0 -1
  219. package/dist/rest.integration.test.js +0 -156
  220. package/dist/rest.integration.test.js.map +0 -1
  221. package/dist/schema-validator/index.js +0 -19
  222. package/dist/schema-validator/index.js.map +0 -1
  223. package/dist/schema-validator/schema-validation-error.js +0 -15
  224. package/dist/schema-validator/schema-validation-error.js.map +0 -1
  225. package/dist/schema-validator/schema-validator.js.map +0 -1
  226. package/dist/schema-validator/schema-validator.test.js +0 -62
  227. package/dist/schema-validator/schema-validator.test.js.map +0 -1
  228. package/dist/schema-validator/validate-examples.js.map +0 -1
  229. package/dist/server-manager.js.map +0 -1
  230. package/dist/server-response-extensions.js +0 -17
  231. package/dist/server-response-extensions.js.map +0 -1
  232. package/dist/server-response-extensions.spec.js +0 -49
  233. package/dist/server-response-extensions.spec.js.map +0 -1
  234. package/dist/static-server-manager.js.map +0 -1
  235. package/dist/static-server-manager.spec.js +0 -218
  236. package/dist/static-server-manager.spec.js.map +0 -1
  237. package/dist/utils.js.map +0 -1
  238. package/dist/validate.integration.schema.js +0 -3
  239. package/dist/validate.integration.spec.js +0 -216
  240. package/dist/validate.integration.spec.js.map +0 -1
  241. package/dist/validate.js.map +0 -1
  242. package/types/actions/error-action.spec.d.ts +0 -2
  243. package/types/actions/error-action.spec.d.ts.map +0 -1
  244. package/types/actions/get-current-user.spec.d.ts +0 -2
  245. package/types/actions/get-current-user.spec.d.ts.map +0 -1
  246. package/types/actions/is-authenticated.spec.d.ts +0 -2
  247. package/types/actions/is-authenticated.spec.d.ts.map +0 -1
  248. package/types/actions/login-action.spec.d.ts +0 -2
  249. package/types/actions/login-action.spec.d.ts.map +0 -1
  250. package/types/actions/logout-action.spec.d.ts +0 -2
  251. package/types/actions/logout-action.spec.d.ts.map +0 -1
  252. package/types/actions/not-found-action.spec.d.ts +0 -2
  253. package/types/actions/not-found-action.spec.d.ts.map +0 -1
  254. package/types/add-cors-header.spec.d.ts +0 -2
  255. package/types/add-cors-header.spec.d.ts.map +0 -1
  256. package/types/authenticate.spec.d.ts +0 -2
  257. package/types/authenticate.spec.d.ts.map +0 -1
  258. package/types/authorize.spec.d.ts +0 -2
  259. package/types/authorize.spec.d.ts.map +0 -1
  260. package/types/endpoint-generators/create-delete-endpoint.spec.d.ts +0 -2
  261. package/types/endpoint-generators/create-delete-endpoint.spec.d.ts.map +0 -1
  262. package/types/endpoint-generators/create-get-collection-endpoint.spec.d.ts +0 -2
  263. package/types/endpoint-generators/create-get-collection-endpoint.spec.d.ts.map +0 -1
  264. package/types/endpoint-generators/create-get-entity-endpoint.spec.d.ts +0 -2
  265. package/types/endpoint-generators/create-get-entity-endpoint.spec.d.ts.map +0 -1
  266. package/types/endpoint-generators/create-patch-endpoint.spec.d.ts +0 -2
  267. package/types/endpoint-generators/create-patch-endpoint.spec.d.ts.map +0 -1
  268. package/types/endpoint-generators/create-post-endpoint.spec.d.ts +0 -2
  269. package/types/endpoint-generators/create-post-endpoint.spec.d.ts.map +0 -1
  270. package/types/helpers.spec.d.ts +0 -2
  271. package/types/helpers.spec.d.ts.map +0 -1
  272. package/types/http-user-context.spec.d.ts +0 -3
  273. package/types/http-user-context.spec.d.ts.map +0 -1
  274. package/types/incoming-message-extensions.spec.d.ts +0 -2
  275. package/types/incoming-message-extensions.spec.d.ts.map +0 -1
  276. package/types/mime-types.spec.d.ts +0 -2
  277. package/types/mime-types.spec.d.ts.map +0 -1
  278. package/types/rest-service.integration.spec.d.ts +0 -2
  279. package/types/rest-service.integration.spec.d.ts.map +0 -1
  280. package/types/rest.integration.test.d.ts +0 -90
  281. package/types/rest.integration.test.d.ts.map +0 -1
  282. package/types/schema-validator/schema-validator.test.d.ts +0 -2
  283. package/types/schema-validator/schema-validator.test.d.ts.map +0 -1
  284. package/types/server-response-extensions.spec.d.ts +0 -2
  285. package/types/server-response-extensions.spec.d.ts.map +0 -1
  286. package/types/static-server-manager.spec.d.ts +0 -2
  287. package/types/static-server-manager.spec.d.ts.map +0 -1
  288. package/types/validate.integration.spec.d.ts +0 -2
  289. package/types/validate.integration.spec.d.ts.map +0 -1
  290. /package/{dist → esm}/models/cors-options.js.map +0 -0
  291. /package/{dist → esm}/validate.integration.schema.js.map +0 -0
  292. /package/{dist → esm}/validate.integration.spec.schema.json +0 -0
@@ -2,7 +2,7 @@ import { Injectable } from '@furystack/inject'
2
2
  import type { Disposable } from '@furystack/utils'
3
3
  import type { Server } from 'http'
4
4
  import { createServer } from 'http'
5
- import Semaphore from 'semaphore-async-await'
5
+ import { Lock } from 'semaphore-async-await'
6
6
  import type { IncomingMessage, ServerResponse } from 'http'
7
7
  import type { Socket } from 'net'
8
8
 
@@ -33,7 +33,7 @@ export class ServerManager implements Disposable {
33
33
  public servers = new Map<string, ServerRecord>()
34
34
  private openedSockets = new Set<Socket>()
35
35
 
36
- private readonly listenLock = new Semaphore(1)
36
+ private readonly listenLock = new Lock()
37
37
 
38
38
  private getHostUrl = (options: ServerOptions) =>
39
39
  `http://${options.hostName || ServerManager.DEFAULT_HOST}:${options.port}`
@@ -2,6 +2,7 @@ import { Socket } from 'net'
2
2
  import { IncomingMessage, ServerResponse } from 'http'
3
3
  import './server-response-extensions'
4
4
  import { BypassResult, JsonResult, PlainTextResult } from './request-action-implementation'
5
+ import { describe, it, expect, vi } from 'vitest'
5
6
 
6
7
  describe('ServerResponse extensions', () => {
7
8
  describe('sendActionResult', () => {
@@ -11,39 +12,43 @@ describe('ServerResponse extensions', () => {
11
12
  expect(typeof msg.sendActionResult).toBe('function')
12
13
  })
13
14
 
14
- it('Should send the JSON response with the correct Content Type header and default status', (done) => {
15
+ it('Should send the JSON response with the correct Content Type header and default status', async () => {
15
16
  const jsonValue = { value: Math.random() }
16
17
  const socket = new Socket()
17
18
  const msg = new ServerResponse(new IncomingMessage(socket))
18
- msg.writeHead = jest.fn()
19
- msg.end = ((chunk: any) => {
20
- expect(chunk).toBe(JSON.stringify(jsonValue))
21
- expect(msg.writeHead).toBeCalledWith(200, { 'Content-Type': 'application/json' })
22
- done()
23
- }) as (typeof msg)['end']
19
+ msg.writeHead = vi.fn() as any
20
+ await new Promise<void>((done) => {
21
+ msg.end = ((chunk: any) => {
22
+ expect(chunk).toBe(JSON.stringify(jsonValue))
23
+ expect(msg.writeHead).toBeCalledWith(200, { 'Content-Type': 'application/json' })
24
+ done()
25
+ }) as (typeof msg)['end']
24
26
 
25
- msg.sendActionResult(JsonResult(jsonValue))
27
+ msg.sendActionResult(JsonResult(jsonValue))
28
+ })
26
29
  })
27
30
 
28
- it('Should send the plain TEXT response with the correct Content Type header and default status', (done) => {
31
+ it('Should send the plain TEXT response with the correct Content Type header and default status', async () => {
29
32
  const textValue = `${Math.random()}`
30
33
  const socket = new Socket()
31
34
  const msg = new ServerResponse(new IncomingMessage(socket))
32
- msg.writeHead = jest.fn()
33
- msg.end = ((chunk: any) => {
34
- expect(chunk).toBe(textValue)
35
- expect(msg.writeHead).toBeCalledWith(200, { 'Content-Type': 'plain/text' })
36
- done()
37
- }) as (typeof msg)['end']
35
+ await new Promise<void>((done) => {
36
+ msg.writeHead = vi.fn() as any
37
+ msg.end = ((chunk: any) => {
38
+ expect(chunk).toBe(textValue)
39
+ expect(msg.writeHead).toBeCalledWith(200, { 'Content-Type': 'plain/text' })
40
+ done()
41
+ }) as (typeof msg)['end']
38
42
 
39
- msg.sendActionResult(PlainTextResult(textValue))
43
+ msg.sendActionResult(PlainTextResult(textValue))
44
+ })
40
45
  })
41
46
 
42
47
  it('Should skip sending on BypassResult', () => {
43
48
  const socket = new Socket()
44
49
  const msg = new ServerResponse(new IncomingMessage(socket))
45
- msg.writeHead = jest.fn()
46
- msg.end = jest.fn()
50
+ msg.writeHead = vi.fn() as any
51
+ msg.end = vi.fn() as any
47
52
 
48
53
  msg.sendActionResult(BypassResult())
49
54
  expect(msg.writeHead).not.toBeCalled()
@@ -2,10 +2,10 @@ import { Injector } from '@furystack/inject'
2
2
  import { sleepAsync, usingAsync } from '@furystack/utils'
3
3
  import { ServerManager } from './server-manager'
4
4
  import { StaticServerManager } from './static-server-manager'
5
+ import { describe, it, expect, vi } from 'vitest'
5
6
 
6
7
  /**
7
8
  * Generator for an incremental port number
8
- *
9
9
  * @param initialPort The initial port number
10
10
  * @yields a port for testing
11
11
  * @returns The Port number
@@ -139,7 +139,7 @@ describe('StaticServerManager', () => {
139
139
 
140
140
  const server = [...injector.getInstance(ServerManager).servers.values()][0]
141
141
 
142
- server.apis[0].onRequest = jest.fn()
142
+ server.apis[0].onRequest = vi.fn()
143
143
 
144
144
  fetch(`http://localhost:${port}/bundleToAnotherFolder/not-found.html`).catch(() => {
145
145
  /** should fall, ignore */
package/src/utils.ts CHANGED
@@ -32,7 +32,6 @@ export class Utils {
32
32
 
33
33
  /**
34
34
  * Reads the post's body and returns a promise with a parsed value
35
- *
36
35
  * @param incomingMessage The incoming message instance
37
36
  * @returns the parsed object from the post body
38
37
  */
@@ -44,7 +43,6 @@ export class Utils {
44
43
 
45
44
  /**
46
45
  * Adds the specified CORS headers to the response
47
- *
48
46
  * @param options The CORS Options object
49
47
  * @param incomingMessage The incoming message instance
50
48
  * @param serverResponse The outgoing response instance
@@ -8,6 +8,7 @@ import './helpers'
8
8
  import schema from './validate.integration.spec.schema.json'
9
9
  import type { ValidationApi } from './validate.integration.schema'
10
10
  import { useRestService } from './helpers'
11
+ import { describe, it, expect } from 'vitest'
11
12
 
12
13
  // To recreate: yarn ts-json-schema-generator -f tsconfig.json --no-type-check -p packages/rest-service/src/validate.integration.schema.ts -o packages/rest-service/src/validate.integration.spec.schema.json
13
14
 
@@ -2,7 +2,6 @@ import type { User } from '@furystack/core';
2
2
  import type { RequestAction } from '../request-action-implementation';
3
3
  /**
4
4
  * Action that returns the current authenticated user
5
- *
6
5
  * @param injector The injector from the current stack
7
6
  */
8
7
  export declare const GetCurrentUser: RequestAction<{
@@ -1 +1 @@
1
- {"version":3,"file":"get-current-user.d.ts","sourceRoot":"","sources":["../../src/actions/get-current-user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAG3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAGrE;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC;IACzC,MAAM,EAAE,IAAI,CAAA;CACb,CAGC,CAAA"}
1
+ {"version":3,"file":"get-current-user.d.ts","sourceRoot":"","sources":["../../src/actions/get-current-user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAG3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAGrE;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,aAAa,CAAC;IACzC,MAAM,EAAE,IAAI,CAAA;CACb,CAGC,CAAA"}
@@ -1,7 +1,6 @@
1
1
  import type { RequestAction } from '../request-action-implementation';
2
2
  /**
3
3
  * Action that returns if the current user is authenticated
4
- *
5
4
  * @param options The options for the Custom Action
6
5
  * @param options.injector The Injector from the current context
7
6
  * @returns A standard authentication result
@@ -1 +1 @@
1
- {"version":3,"file":"is-authenticated.d.ts","sourceRoot":"","sources":["../../src/actions/is-authenticated.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAGrE;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC;IAAE,MAAM,EAAE;QAAE,eAAe,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,CAGnF,CAAA"}
1
+ {"version":3,"file":"is-authenticated.d.ts","sourceRoot":"","sources":["../../src/actions/is-authenticated.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAGrE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC;IAAE,MAAM,EAAE;QAAE,eAAe,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,CAGnF,CAAA"}
@@ -1,7 +1,6 @@
1
1
  import type { RequestAction } from '../request-action-implementation';
2
2
  /**
3
3
  * Action that logs out the current user
4
- *
5
4
  * @param root0 The Options object
6
5
  * @param root0.injector The injector from the context
7
6
  * @param root0.request The current Request object
@@ -1 +1 @@
1
- {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/actions/logout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAGrE;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,aAAa,CAAC;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAG3D,CAAA"}
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/actions/logout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAGrE;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,aAAa,CAAC;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAG3D,CAAA"}
@@ -4,7 +4,6 @@ import '@furystack/repository';
4
4
  import type { RequestAction } from '../request-action-implementation';
5
5
  /**
6
6
  * Creates a DELETE endpoint for removing entities
7
- *
8
7
  * @param options The options for endpoint creation
9
8
  * @param options.model The Model class
10
9
  * @param options.primaryKey The field used as primary key on the model
@@ -1 +1 @@
1
- {"version":3,"file":"create-delete-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-delete-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAIrE;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB;;;mDAWhC,CAAA"}
1
+ {"version":3,"file":"create-delete-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-delete-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAIrE;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;mDAWhC,CAAA"}
@@ -4,7 +4,6 @@ import '@furystack/repository';
4
4
  import type { RequestAction } from '../request-action-implementation';
5
5
  /**
6
6
  * Creates a GetCollection endpoint for the given model. The model should have a Repository DataSet
7
- *
8
7
  * @param options The options for endpoint creation
9
8
  * @param options.model The Model class
10
9
  * @param options.primaryKey The field used as primary key on the model
@@ -1 +1 @@
1
- {"version":3,"file":"create-get-collection-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-collection-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAIrE;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B;;;6CAcvC,CAAA"}
1
+ {"version":3,"file":"create-get-collection-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-collection-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAIrE;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B;;;6CAcvC,CAAA"}
@@ -4,7 +4,6 @@ import '@furystack/repository';
4
4
  import type { RequestAction } from '../request-action-implementation';
5
5
  /**
6
6
  * Creates a simple Get Entity endpoint for a specified model.
7
- *
8
7
  * @param options The options for endpoint creation
9
8
  * @param options.model The entity model, should have a Repository DataSet
10
9
  * @param options.primaryKey The field name used as primary key on the model
@@ -1 +1 @@
1
- {"version":3,"file":"create-get-entity-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-entity-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAExD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAIrE;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB;;;sDAenC,CAAA"}
1
+ {"version":3,"file":"create-get-entity-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-get-entity-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAExD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAIrE;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB;;;sDAenC,CAAA"}
@@ -6,7 +6,6 @@ import type { RequestAction } from '../request-action-implementation';
6
6
  import type { WithOptionalId } from '@furystack/core';
7
7
  /**
8
8
  * Creates a PATCH endpoint for updating entities
9
- *
10
9
  * @param options The options for endpoint creation
11
10
  * @param options.model The Model class
12
11
  * @param options.primaryKey The field name that is used as primary key on the model
@@ -1 +1 @@
1
- {"version":3,"file":"create-patch-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-patch-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAGrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErD;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;iEAoB/B,CAAA"}
1
+ {"version":3,"file":"create-patch-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-patch-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAGrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErD;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB;;;iEAoB/B,CAAA"}
@@ -6,7 +6,6 @@ import type { RequestAction } from '../request-action-implementation';
6
6
  import type { WithOptionalId } from '@furystack/core';
7
7
  /**
8
8
  * Creates a POST endpoint for updating entities
9
- *
10
9
  * @param options The options for endpoint creation
11
10
  * @param options.model The Model class
12
11
  * @param options.primaryKey The field name used as primary key
@@ -1 +1 @@
1
- {"version":3,"file":"create-post-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-post-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErD;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;gEAsB9B,CAAA"}
1
+ {"version":3,"file":"create-post-endpoint.d.ts","sourceRoot":"","sources":["../../src/endpoint-generators/create-post-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;;;gEAsB9B,CAAA"}
@@ -7,13 +7,12 @@ import type { DefaultSession } from './models/default-session';
7
7
  import type { StaticServerOptions } from './static-server-manager';
8
8
  /**
9
9
  * Sets up the @furystack/rest-service with the provided settings
10
- *
11
10
  * @param api The API implementation details
11
+ * @returns a promise that resolves when the API is added to the server
12
12
  */
13
- export declare const useRestService: <T extends RestApi>(api: ImplementApiOptions<T>) => Promise<undefined>;
13
+ export declare const useRestService: <T extends RestApi>(api: ImplementApiOptions<T>) => Promise<void>;
14
14
  /**
15
15
  * Sets up the HTTP Authentication
16
- *
17
16
  * @param injector The Injector instance
18
17
  * @param settings Settings for HTTP Authentication
19
18
  * @returns void
@@ -21,7 +20,6 @@ export declare const useRestService: <T extends RestApi>(api: ImplementApiOption
21
20
  export declare const useHttpAuthentication: <TUser extends User, TSession extends DefaultSession>(injector: Injector, settings?: Partial<HttpAuthenticationSettings<TUser, TSession>> | undefined) => void;
22
21
  /**
23
22
  * Sets up a static file server
24
- *
25
23
  * @param options The settings for the static file server
26
24
  * @param options.injector The Injector instance
27
25
  * @param options.settings Settings for the static file server
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO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@@ -18,7 +18,6 @@ export declare class HttpUserContext {
18
18
  isAuthenticated(request: IncomingMessage): Promise<boolean>;
19
19
  /**
20
20
  * Returns if the current user can be authorized with ALL of the specified roles
21
- *
22
21
  * @param request The request to be authenticated
23
22
  * @param roles The list of roles to authorize
24
23
  * @returns a boolean value that indicates if the user is authenticated
@@ -26,7 +25,6 @@ export declare class HttpUserContext {
26
25
  isAuthorized(request: IncomingMessage, ...roles: string[]): Promise<boolean>;
27
26
  /**
28
27
  * Checks if the system contains a user with the provided name and password, throws an error otherwise
29
- *
30
28
  * @param userName The username
31
29
  * @param password The password
32
30
  * @returns the authenticated User
@@ -37,7 +35,6 @@ export declare class HttpUserContext {
37
35
  authenticateRequest(request: IncomingMessage): Promise<User>;
38
36
  /**
39
37
  * Creates and sets up a cookie-based session for the provided user
40
- *
41
38
  * @param user The user to create a session for
42
39
  * @param serverResponse A serverResponse to set the cookie
43
40
  * @returns the current User
@@ -1 +1 @@
1
- {"version":3,"file":"http-user-context.d.ts","sourceRoot":"","sources":["../src/http-user-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAG3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAA;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAI9D;;GAEG;AACH,qBACa,eAAe;IACnB,YAAY,8HAA4D;IAExE,eAAe,sKAA+D;IAErF,OAAO,CAAC,aAAa,CAOpB;IAED,OAAO,CAAC,cAAc,CAOrB;IAED,OAAO,CAAC,IAAI,CAAC,CAAM;IAEnB;;;OAGG;IACU,eAAe,CAAC,OAAO,EAAE,eAAe;IASrD;;;;;;OAMG;IACU,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAA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AC,UAAU,CAC0D;IAE5E,OAAO,CAAC,YAAY,CAGnB;IAEY,OAAO;IAmBP,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CA6BxE"}
package/types/utils.d.ts CHANGED
@@ -7,14 +7,12 @@ export declare class Utils {
7
7
  readPostBodyRaw(incomingMessage: IncomingMessage): Promise<string>;
8
8
  /**
9
9
  * Reads the post's body and returns a promise with a parsed value
10
- *
11
10
  * @param incomingMessage The incoming message instance
12
11
  * @returns the parsed object from the post body
13
12
  */
14
13
  readPostBody<T>(incomingMessage: IncomingMessage): Promise<T>;
15
14
  /**
16
15
  * Adds the specified CORS headers to the response
17
- *
18
16
  * @param options The CORS Options object
19
17
  * @param incomingMessage The incoming message instance
20
18
  * @param serverResponse The outgoing response instance
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD;;GAEG;AACH,qBACa,KAAK;IACH,eAAe,CAAC,eAAe,EAAE,eAAe;IAuB7D;;;;;OAKG;IACU,YAAY,CAAC,CAAC,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC;IAM1E;;;;;;OAMG;IACI,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc;CAkB7G"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD;;GAEG;AACH,qBACa,KAAK;IACH,eAAe,CAAC,eAAe,EAAE,eAAe;IAuB7D;;;;OAIG;IACU,YAAY,CAAC,CAAC,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC;IAM1E;;;;;OAKG;IACI,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc;CAkB7G"}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ErrorAction = void 0;
4
- const rest_1 = require("@furystack/rest");
5
- const core_1 = require("@furystack/core");
6
- const request_action_implementation_1 = require("../request-action-implementation");
7
- const schema_validator_1 = require("../schema-validator");
8
- /**
9
- * Action for unhandled (500) errors
10
- * Returns a serialized error instance in JSON format.
11
- */
12
- const ErrorAction = async ({ getBody }) => {
13
- const body = await getBody();
14
- if (body instanceof schema_validator_1.SchemaValidationError) {
15
- return (0, request_action_implementation_1.JsonResult)({ message: body.message, errors: body.errors }, 400);
16
- }
17
- if (body instanceof rest_1.RequestError) {
18
- return (0, request_action_implementation_1.JsonResult)({ message: body.message }, body.responseCode);
19
- }
20
- if (body instanceof core_1.AuthorizationError) {
21
- return (0, request_action_implementation_1.JsonResult)({ message: body.message }, 403);
22
- }
23
- if (body instanceof Error) {
24
- return (0, request_action_implementation_1.JsonResult)({ message: body.message }, 500);
25
- }
26
- return (0, request_action_implementation_1.JsonResult)({ message: 'An unexpected error happened' }, 500);
27
- };
28
- exports.ErrorAction = ErrorAction;
29
- //# sourceMappingURL=error-action.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-action.js","sourceRoot":"","sources":["../../src/actions/error-action.ts"],"names":[],"mappings":";;;AAAA,0CAA8C;AAC9C,0CAAoD;AAEpD,oFAA6D;AAC7D,0DAA2D;AAE3D;;;GAGG;AAEI,MAAM,WAAW,GAGnB,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IACzB,MAAM,IAAI,GAAG,MAAM,OAAO,EAAE,CAAA;IAE5B,IAAI,IAAI,YAAY,wCAAqB,EAAE;QACzC,OAAO,IAAA,0CAAU,EAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,CAAA;KACvE;IAED,IAAI,IAAI,YAAY,mBAAY,EAAE;QAChC,OAAO,IAAA,0CAAU,EAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;KAChE;IAED,IAAI,IAAI,YAAY,yBAAkB,EAAE;QACtC,OAAO,IAAA,0CAAU,EAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAA;KAClD;IAED,IAAI,IAAI,YAAY,KAAK,EAAE;QACzB,OAAO,IAAA,0CAAU,EAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,CAAA;KAClD;IAED,OAAO,IAAA,0CAAU,EAAC,EAAE,OAAO,EAAE,8BAA8B,EAAE,EAAE,GAAG,CAAC,CAAA;AACrE,CAAC,CAAA;AAvBY,QAAA,WAAW,eAuBvB"}
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const inject_1 = require("@furystack/inject");
4
- const utils_1 = require("@furystack/utils");
5
- const error_action_1 = require("./error-action");
6
- const rest_1 = require("@furystack/rest");
7
- const core_1 = require("@furystack/core");
8
- describe('ErrorAction tests', () => {
9
- const request = { url: 'https://google.com' };
10
- const response = {};
11
- it('returns the error in the standard format', async () => {
12
- await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
13
- const result = await (0, error_action_1.ErrorAction)({
14
- injector: i,
15
- getBody: async () => new Error('Something went wrong'),
16
- request,
17
- response,
18
- });
19
- expect(result.statusCode).toBe(500);
20
- expect(result.chunk.message).toBe('Something went wrong');
21
- });
22
- });
23
- it('returns the error code from request errors', async () => {
24
- await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
25
- const result = await (0, error_action_1.ErrorAction)({
26
- request,
27
- response,
28
- injector: i,
29
- getBody: async () => new rest_1.RequestError('Something went wrong', 401),
30
- });
31
- expect(result.statusCode).toBe(401);
32
- expect(result.chunk.message).toBe('Something went wrong');
33
- });
34
- });
35
- it('returns the 403 for authorization errors', async () => {
36
- await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
37
- const result = await (0, error_action_1.ErrorAction)({
38
- request,
39
- response,
40
- injector: i,
41
- getBody: async () => new core_1.AuthorizationError('Something went wrong'),
42
- });
43
- expect(result.statusCode).toBe(403);
44
- expect(result.chunk.message).toBe('Something went wrong');
45
- });
46
- });
47
- });
48
- //# sourceMappingURL=error-action.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-action.spec.js","sourceRoot":"","sources":["../../src/actions/error-action.spec.ts"],"names":[],"mappings":";;AAAA,8CAA4C;AAC5C,4CAA6C;AAC7C,iDAA4C;AAE5C,0CAA8C;AAC9C,0CAAoD;AAGpD,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,oBAAoB,EAAqB,CAAA;IAChE,MAAM,QAAQ,GAAG,EAAoB,CAAA;IAErC,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;QACxD,MAAM,IAAA,kBAAU,EAAC,IAAI,iBAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;YAC3C,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAW,EAAC;gBAC/B,QAAQ,EAAE,CAAC;gBACX,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC;gBACtD,OAAO;gBACP,QAAQ;aACT,CAAC,CAAA;YACF,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACnC,MAAM,CAAC,MAAM,CA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,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetCurrentUser = void 0;
4
- const core_1 = require("@furystack/core");
5
- const authenticate_1 = require("../authenticate");
6
- const request_action_implementation_1 = require("../request-action-implementation");
7
- /**
8
- * Action that returns the current authenticated user
9
- *
10
- * @param injector The injector from the current stack
11
- */
12
- exports.GetCurrentUser = (0, authenticate_1.Authenticate)()(async ({ injector }) => {
13
- const user = await (0, core_1.getCurrentUser)(injector);
14
- return (0, request_action_implementation_1.JsonResult)(user);
15
- });
16
- //# sourceMappingURL=get-current-user.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-current-user.js","sourceRoot":"","sources":["../../src/actions/get-current-user.ts"],"names":[],"mappings":";;;AACA,0CAAgD;AAChD,kDAA8C;AAE9C,oFAA6D;AAE7D;;;;GAIG;AACU,QAAA,cAAc,GAEtB,IAAA,2BAAY,GAAE,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;IACzC,MAAM,IAAI,GAAG,MAAM,IAAA,qBAAc,EAAC,QAAQ,CAAC,CAAA;IAC3C,OAAO,IAAA,0CAAU,EAAC,IAAI,CAAC,CAAA;AACzB,CAAC,CAAC,CAAA"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const inject_1 = require("@furystack/inject");
4
- const utils_1 = require("@furystack/utils");
5
- const get_current_user_1 = require("./get-current-user");
6
- const core_1 = require("@furystack/core");
7
- describe('getCurrentUser', () => {
8
- const request = { url: 'https://google.com' };
9
- const response = {};
10
- it('exec', async () => {
11
- const testUser = { Name: 'Userke' };
12
- await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
13
- i.setExplicitInstance({ getCurrentUser: async () => testUser, isAuthenticated: async () => true }, core_1.IdentityContext);
14
- const result = await (0, get_current_user_1.GetCurrentUser)({ injector: i, request, response });
15
- expect(result.statusCode).toBe(200);
16
- expect(result.chunk).toEqual(testUser);
17
- });
18
- });
19
- });
20
- //# sourceMappingURL=get-current-user.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-current-user.spec.js","sourceRoot":"","sources":["../../src/actions/get-current-user.spec.ts"],"names":[],"mappings":";;AAAA,8CAA4C;AAC5C,4CAA6C;AAC7C,yDAAmD;AAEnD,0CAAiD;AAEjD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,oBAAoB,EAAqB,CAAA;IAChE,MAAM,QAAQ,GAAG,EAAoB,CAAA;IAErC,EAAE,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;QACpB,MAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;QACnC,MAAM,IAAA,kBAAU,EAAC,IAAI,iBAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;YAC3C,CAAC,CAAC,mBAAmB,CACnB,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,EAAE,eAAe,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,EAAE,EAC3E,sBAAe,CAChB,CAAA;YACD,MAAM,MAAM,GAAG,MAAM,IAAA,iCAAc,EAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAA;YACvE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACnC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACxC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./error-action"), exports);
18
- __exportStar(require("./get-current-user"), exports);
19
- __exportStar(require("./is-authenticated"), exports);
20
- __exportStar(require("./login"), exports);
21
- __exportStar(require("./logout"), exports);
22
- __exportStar(require("./not-found-action"), exports);
23
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,qDAAkC;AAClC,qDAAkC;AAClC,0CAAuB;AACvB,2CAAwB;AACxB,qDAAkC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IsAuthenticated = void 0;
4
- const core_1 = require("@furystack/core");
5
- const request_action_implementation_1 = require("../request-action-implementation");
6
- /**
7
- * Action that returns if the current user is authenticated
8
- *
9
- * @param options The options for the Custom Action
10
- * @param options.injector The Injector from the current context
11
- * @returns A standard authentication result
12
- */
13
- const IsAuthenticated = async ({ injector }) => {
14
- const isAuthenticatedResult = await (0, core_1.isAuthenticated)(injector);
15
- return (0, request_action_implementation_1.JsonResult)({ isAuthenticated: isAuthenticatedResult });
16
- };
17
- exports.IsAuthenticated = IsAuthenticated;
18
- //# sourceMappingURL=is-authenticated.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-authenticated.js","sourceRoot":"","sources":["../../src/actions/is-authenticated.ts"],"names":[],"mappings":";;;AAAA,0CAAiD;AAEjD,oFAA6D;AAE7D;;;;;;GAMG;AACI,MAAM,eAAe,GAA4D,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC7G,MAAM,qBAAqB,GAAG,MAAM,IAAA,sBAAe,EAAC,QAAQ,CAAC,CAAA;IAC7D,OAAO,IAAA,0CAAU,EAAC,EAAE,eAAe,EAAE,qBAAqB,EAAE,CAAC,CAAA;AAC/D,CAAC,CAAA;AAHY,QAAA,eAAe,mBAG3B"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const inject_1 = require("@furystack/inject");
4
- const utils_1 = require("@furystack/utils");
5
- const is_authenticated_1 = require("./is-authenticated");
6
- const core_1 = require("@furystack/core");
7
- describe('isAuthenticated', () => {
8
- const request = { url: 'https://google.com' };
9
- const response = {};
10
- it('exec', async () => {
11
- await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
12
- i.setExplicitInstance({ isAuthenticated: async () => true }, core_1.IdentityContext);
13
- const result = await (0, is_authenticated_1.IsAuthenticated)({ injector: i, request, response });
14
- expect(result.statusCode).toBe(200);
15
- expect(result.chunk).toEqual({ isAuthenticated: true });
16
- });
17
- });
18
- });
19
- //# sourceMappingURL=is-authenticated.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-authenticated.spec.js","sourceRoot":"","sources":["../../src/actions/is-authenticated.spec.ts"],"names":[],"mappings":";;AAAA,8CAA4C;AAC5C,4CAA6C;AAC7C,yDAAoD;AAEpD,0CAAiD;AAEjD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,oBAAoB,EAAqB,CAAA;IAChE,MAAM,QAAQ,GAAG,EAAoB,CAAA;IACrC,EAAE,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;QACpB,MAAM,IAAA,kBAAU,EAAC,IAAI,iBAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;YAC3C,CAAC,CAAC,mBAAmB,CAAC,EAAE,eAAe,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,sBAAe,CAAC,CAAA;YAC7E,MAAM,MAAM,GAAG,MAAM,IAAA,kCAAe,EAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAS,CAAC,CAAA;YAC/E,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACnC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAA;QACzD,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const inject_1 = require("@furystack/inject");
4
- const utils_1 = require("@furystack/utils");
5
- const login_1 = require("./login");
6
- const http_user_context_1 = require("../http-user-context");
7
- describe('LoginAction', () => {
8
- const request = { url: 'https://google.com' };
9
- const response = {};
10
- it('Returns the provided user with 200 on success', async () => {
11
- const testUser = { Name: 'Userke' };
12
- await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
13
- i.setExplicitInstance({
14
- authenticateUser: jest.fn(async () => testUser),
15
- cookieLogin: jest.fn(async () => testUser),
16
- authentication: {},
17
- }, http_user_context_1.HttpUserContext);
18
- const result = await (0, login_1.LoginAction)({
19
- request,
20
- response,
21
- injector: i,
22
- getBody: async () => ({ username: 'testuser', password: 'alma' }),
23
- });
24
- expect(result.chunk).toEqual(testUser);
25
- expect(result.statusCode).toBe(200);
26
- });
27
- });
28
- it('Returns throw error with 400 on fail', async () => {
29
- await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
30
- i.setExplicitInstance({ cookieLogin: async () => Promise.reject(':(') }, http_user_context_1.HttpUserContext);
31
- await expect((0, login_1.LoginAction)({ request, response, injector: i, getBody: async () => ({ username: '', password: '' }) })).rejects.toThrowError('Login Failed');
32
- });
33
- });
34
- });
35
- //# sourceMappingURL=login-action.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"login-action.spec.js","sourceRoot":"","sources":["../../src/actions/login-action.spec.ts"],"names":[],"mappings":";;AACA,8CAA4C;AAC5C,4CAA6C;AAC7C,mCAAqC;AACrC,4DAAsD;AAEtD,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,oBAAoB,EAAqB,CAAA;IAChE,MAAM,QAAQ,GAAG,EAAoB,CAAA;IAErC,EAAE,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;QAC7D,MAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAA;QACnC,MAAM,IAAA,kBAAU,EAAC,IAAI,iBAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;YAC3C,CAAC,CAAC,mBAAmB,CACnB;gBACE,gBAAgB,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,QAAQ,CAAC;gBAC/C,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,QAAQ,CAAC;gBAC1C,cAAc,EAAE,EAAE;aACnB,EACD,mCAAe,CAChB,CAAA;YACD,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAW,EAAC;gBAC/B,OAAO;gBACP,QAAQ;gBACR,QAAQ,EAAE,CAAC;gBACX,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;aAC3D,CAAC,CAAA;YACT,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;YACtC,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