@furystack/rest-service 6.2.1 → 6.2.3
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/dist/actions/error-action.js +5 -5
- package/dist/actions/error-action.js.map +1 -1
- package/dist/actions/error-action.spec.js +0 -3
- package/dist/actions/error-action.spec.js.map +1 -1
- package/dist/api-manager.js +2 -2
- package/dist/api-manager.js.map +1 -1
- package/dist/endpoint-generators/create-delete-endpoint.spec.js +4 -7
- package/dist/endpoint-generators/create-delete-endpoint.spec.js.map +1 -1
- package/dist/endpoint-generators/create-get-collection-endpoint.spec.js +15 -14
- package/dist/endpoint-generators/create-get-collection-endpoint.spec.js.map +1 -1
- package/dist/endpoint-generators/create-get-entity-endpoint.spec.js +12 -18
- package/dist/endpoint-generators/create-get-entity-endpoint.spec.js.map +1 -1
- package/dist/endpoint-generators/create-patch-endpoint.spec.js +4 -7
- package/dist/endpoint-generators/create-patch-endpoint.spec.js.map +1 -1
- package/dist/endpoint-generators/create-post-endpoint.spec.js +5 -8
- package/dist/endpoint-generators/create-post-endpoint.spec.js.map +1 -1
- package/dist/rest-service.integration.spec.js +34 -24
- package/dist/rest-service.integration.spec.js.map +1 -1
- package/dist/rest.integration.test.js +11 -11
- package/dist/rest.integration.test.js.map +1 -1
- package/dist/static-server-manager.spec.js +32 -62
- package/dist/static-server-manager.spec.js.map +1 -1
- package/dist/validate.integration.spec.js +32 -37
- package/dist/validate.integration.spec.js.map +1 -1
- package/package.json +11 -12
- package/src/actions/error-action.spec.ts +0 -3
- package/src/actions/error-action.ts +6 -6
- package/src/api-manager.ts +2 -2
- package/src/endpoint-generators/create-delete-endpoint.spec.ts +4 -4
- package/src/endpoint-generators/create-get-collection-endpoint.spec.ts +17 -11
- package/src/endpoint-generators/create-get-entity-endpoint.spec.ts +12 -16
- package/src/endpoint-generators/create-patch-endpoint.spec.ts +4 -4
- package/src/endpoint-generators/create-post-endpoint.spec.ts +6 -6
- package/src/rest-service.integration.spec.ts +36 -29
- package/src/rest.integration.test.ts +10 -10
- package/src/static-server-manager.spec.ts +32 -39
- package/src/validate.integration.spec.ts +31 -36
- package/types/actions/error-action.d.ts +0 -2
- package/types/actions/error-action.d.ts.map +1 -1
- package/types/validate.integration.spec.d.ts.map +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Injector } from '@furystack/inject'
|
|
2
|
-
import { createClient } from '@furystack/rest-client-
|
|
2
|
+
import { createClient, ResponseError } from '@furystack/rest-client-fetch'
|
|
3
3
|
import { usingAsync } from '@furystack/utils'
|
|
4
|
-
import { RequestError } from 'got/dist/source'
|
|
5
4
|
import { JsonResult } from './request-action-implementation'
|
|
6
5
|
import { Validate } from './validate'
|
|
7
6
|
import './helpers'
|
|
@@ -75,10 +74,10 @@ describe('Validation integration tests', () => {
|
|
|
75
74
|
query: undefined as any,
|
|
76
75
|
})
|
|
77
76
|
} catch (error) {
|
|
78
|
-
if (error instanceof
|
|
79
|
-
expect(error.message).toBe('
|
|
80
|
-
expect(error.response?.
|
|
81
|
-
const responseJson =
|
|
77
|
+
if (error instanceof ResponseError) {
|
|
78
|
+
expect(error.message).toBe('Bad Request')
|
|
79
|
+
expect(error.response?.status).toBe(400)
|
|
80
|
+
const responseJson = await error.response.json()
|
|
82
81
|
expect(responseJson.errors[0].params.missingProperty).toEqual('foo')
|
|
83
82
|
expect(responseJson.errors[1].params.missingProperty).toEqual('bar')
|
|
84
83
|
expect(responseJson.errors[2].params.missingProperty).toEqual('baz')
|
|
@@ -96,10 +95,10 @@ describe('Validation integration tests', () => {
|
|
|
96
95
|
url: undefined as any,
|
|
97
96
|
})
|
|
98
97
|
} catch (error) {
|
|
99
|
-
if (error instanceof
|
|
100
|
-
expect(error.message).toBe('
|
|
101
|
-
expect(error.response?.
|
|
102
|
-
const responseJson =
|
|
98
|
+
if (error instanceof ResponseError) {
|
|
99
|
+
expect(error.message).toBe('Bad Request')
|
|
100
|
+
expect(error.response?.status).toBe(400)
|
|
101
|
+
const responseJson = await error.response.json()
|
|
103
102
|
expect(responseJson.errors[0].params.type).toEqual('number')
|
|
104
103
|
expect(responseJson.errors[0].instancePath).toEqual('/url/id')
|
|
105
104
|
}
|
|
@@ -116,10 +115,10 @@ describe('Validation integration tests', () => {
|
|
|
116
115
|
headers: undefined as any,
|
|
117
116
|
})
|
|
118
117
|
} catch (error) {
|
|
119
|
-
if (error instanceof
|
|
120
|
-
expect(error.message).toBe('
|
|
121
|
-
expect(error.response?.
|
|
122
|
-
const responseJson =
|
|
118
|
+
if (error instanceof ResponseError) {
|
|
119
|
+
expect(error.message).toBe('Bad Request')
|
|
120
|
+
expect(error.response?.status).toBe(400)
|
|
121
|
+
const responseJson = await error.response.json()
|
|
123
122
|
expect(
|
|
124
123
|
responseJson.errors.find((e: any) => e.keyword === 'required' && e.message.includes('foo')),
|
|
125
124
|
).toBeDefined()
|
|
@@ -137,10 +136,10 @@ describe('Validation integration tests', () => {
|
|
|
137
136
|
body: undefined as any,
|
|
138
137
|
})
|
|
139
138
|
} catch (error) {
|
|
140
|
-
if (error instanceof
|
|
141
|
-
expect(error.message).toBe('
|
|
142
|
-
expect(error.response?.
|
|
143
|
-
const responseJson =
|
|
139
|
+
if (error instanceof ResponseError) {
|
|
140
|
+
expect(error.message).toBe('Bad Request')
|
|
141
|
+
expect(error.response?.status).toBe(400)
|
|
142
|
+
const responseJson = await error.response.json()
|
|
144
143
|
expect(responseJson.errors[0].params.missingProperty).toEqual('body')
|
|
145
144
|
}
|
|
146
145
|
}
|
|
@@ -160,11 +159,10 @@ describe('Validation integration tests', () => {
|
|
|
160
159
|
baz: false,
|
|
161
160
|
},
|
|
162
161
|
})
|
|
163
|
-
expect(result.response.
|
|
164
|
-
|
|
165
|
-
expect(
|
|
166
|
-
expect(
|
|
167
|
-
expect(responseJson.baz).toBe(false)
|
|
162
|
+
expect(result.response.status).toBe(200)
|
|
163
|
+
expect(result.result.foo).toBe('foo')
|
|
164
|
+
expect(result.result.bar).toBe(2)
|
|
165
|
+
expect(result.result.baz).toBe(false)
|
|
168
166
|
})
|
|
169
167
|
})
|
|
170
168
|
it('Should validate url', async () => {
|
|
@@ -174,9 +172,8 @@ describe('Validation integration tests', () => {
|
|
|
174
172
|
action: '/validate-url/:id',
|
|
175
173
|
url: { id: 3 },
|
|
176
174
|
})
|
|
177
|
-
expect(result.response.
|
|
178
|
-
|
|
179
|
-
expect(responseJson.id).toBe(3)
|
|
175
|
+
expect(result.response.status).toBe(200)
|
|
176
|
+
expect(result.result.id).toBe(3)
|
|
180
177
|
})
|
|
181
178
|
})
|
|
182
179
|
it('Should validate headers', async () => {
|
|
@@ -190,11 +187,10 @@ describe('Validation integration tests', () => {
|
|
|
190
187
|
baz: true,
|
|
191
188
|
},
|
|
192
189
|
})
|
|
193
|
-
expect(result.response.
|
|
194
|
-
|
|
195
|
-
expect(
|
|
196
|
-
expect(
|
|
197
|
-
expect(responseJson.baz).toBe(true)
|
|
190
|
+
expect(result.response.status).toBe(200)
|
|
191
|
+
expect(result.result.foo).toBe('foo')
|
|
192
|
+
expect(result.result.bar).toBe(42)
|
|
193
|
+
expect(result.result.baz).toBe(true)
|
|
198
194
|
})
|
|
199
195
|
})
|
|
200
196
|
it('Should validate body', async () => {
|
|
@@ -209,11 +205,10 @@ describe('Validation integration tests', () => {
|
|
|
209
205
|
},
|
|
210
206
|
})
|
|
211
207
|
|
|
212
|
-
expect(result.response.
|
|
213
|
-
|
|
214
|
-
expect(
|
|
215
|
-
expect(
|
|
216
|
-
expect(responseJson.baz).toBe(true)
|
|
208
|
+
expect(result.response.status).toBe(200)
|
|
209
|
+
expect(result.result.foo).toBe('foo')
|
|
210
|
+
expect(result.result.bar).toBe(42)
|
|
211
|
+
expect(result.result.baz).toBe(true)
|
|
217
212
|
})
|
|
218
213
|
})
|
|
219
214
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-action.d.ts","sourceRoot":"","sources":["../../src/actions/error-action.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAIrE;;;GAGG;AAEH,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC;IACtC,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"error-action.d.ts","sourceRoot":"","sources":["../../src/actions/error-action.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAIrE;;;GAGG;AAEH,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC;IACtC,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAC5B,CAoBA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.integration.spec.d.ts","sourceRoot":"","sources":["../src/validate.integration.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate.integration.spec.d.ts","sourceRoot":"","sources":["../src/validate.integration.spec.ts"],"names":[],"mappings":"AAKA,OAAO,WAAW,CAAA"}
|