@labdigital/commercetools-mock 2.47.0 → 2.47.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.
- package/dist/index.cjs +139 -144
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +142 -147
- package/dist/index.js.map +1 -1
- package/package.json +24 -25
- package/src/ctMock.ts +6 -3
- package/src/oauth/server.test.ts +8 -0
- package/src/oauth/server.ts +15 -11
- package/src/services/abstract.ts +25 -15
- package/src/services/cart.ts +3 -2
- package/src/services/custom-object.ts +8 -6
- package/src/services/customer.ts +4 -4
- package/src/services/my-cart.ts +3 -2
- package/src/services/my-customer.ts +16 -12
- package/src/services/order.ts +4 -3
- package/src/services/product-projection.ts +2 -2
- package/src/services/product.ts +1 -1
- package/src/services/project.ts +4 -3
- package/src/services/shipping-method.ts +4 -2
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labdigital/commercetools-mock",
|
|
3
|
-
"version": "2.47.
|
|
3
|
+
"version": "2.47.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Michael van Tellingen",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
10
|
"import": "./dist/index.js",
|
|
11
|
-
"
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"main": "dist/index.cjs",
|
|
@@ -19,47 +19,46 @@
|
|
|
19
19
|
"src"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@biomejs/biome": "
|
|
22
|
+
"@biomejs/biome": "1.9.4",
|
|
23
|
+
"@types/express": "^5.0.1",
|
|
24
|
+
"@types/express-serve-static-core": "^5.0.6",
|
|
23
25
|
"basic-auth": "2.0.1",
|
|
24
|
-
"body-parser": "
|
|
25
|
-
"decimal.js": "10.
|
|
26
|
+
"body-parser": "2.2.0",
|
|
27
|
+
"decimal.js": "10.5.0",
|
|
26
28
|
"deep-equal": "2.2.3",
|
|
27
|
-
"express": "
|
|
28
|
-
"light-my-request": "
|
|
29
|
+
"express": "5.1.0",
|
|
30
|
+
"light-my-request": "6.6.0",
|
|
29
31
|
"lodash.isequal": "4.5.0",
|
|
30
32
|
"morgan": "1.10.0",
|
|
31
|
-
"msw": "2.
|
|
32
|
-
"uuid": "
|
|
33
|
-
"zod": "3.
|
|
34
|
-
"zod-validation-error": "3.0
|
|
33
|
+
"msw": "2.7.3",
|
|
34
|
+
"uuid": "11.1.0",
|
|
35
|
+
"zod": "3.24.2",
|
|
36
|
+
"zod-validation-error": "3.4.0"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
|
-
"@changesets/changelog-github": "0.5.
|
|
38
|
-
"@changesets/cli": "2.
|
|
39
|
+
"@changesets/changelog-github": "0.5.1",
|
|
40
|
+
"@changesets/cli": "2.28.1",
|
|
39
41
|
"@commercetools/platform-sdk": "8.8.0",
|
|
40
42
|
"@types/basic-auth": "1.1.8",
|
|
41
43
|
"@types/body-parser": "1.19.5",
|
|
42
44
|
"@types/deep-equal": "1.0.4",
|
|
43
|
-
"@types/express": "4.17.21",
|
|
44
|
-
"@types/express-serve-static-core": "4.17.43",
|
|
45
45
|
"@types/lodash.isequal": "4.5.8",
|
|
46
46
|
"@types/morgan": "1.9.9",
|
|
47
47
|
"@types/node": "20.16.14",
|
|
48
48
|
"@types/qs": "6.9.11",
|
|
49
49
|
"@types/supertest": "6.0.2",
|
|
50
50
|
"@types/uuid": "9.0.8",
|
|
51
|
-
"@vitest/coverage-v8": "3.
|
|
52
|
-
"esbuild": "0.
|
|
53
|
-
"fishery": "2.2.
|
|
51
|
+
"@vitest/coverage-v8": "3.1.1",
|
|
52
|
+
"esbuild": "0.25.2",
|
|
53
|
+
"fishery": "2.2.3",
|
|
54
54
|
"got": "14.2.0",
|
|
55
|
-
"husky": "9.
|
|
56
|
-
"supertest": "
|
|
55
|
+
"husky": "9.1.7",
|
|
56
|
+
"supertest": "7.1.0",
|
|
57
57
|
"timekeeper": "2.3.1",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"tsup": "8.0.2",
|
|
58
|
+
"tslib": "2.8.1",
|
|
59
|
+
"tsup": "8.4.0",
|
|
61
60
|
"typescript": "5.8.3",
|
|
62
|
-
"vitest": "3.
|
|
61
|
+
"vitest": "3.1.1"
|
|
63
62
|
},
|
|
64
63
|
"engines": {
|
|
65
64
|
"node": ">=18",
|
package/src/ctMock.ts
CHANGED
|
@@ -170,23 +170,26 @@ export class CommercetoolsMock {
|
|
|
170
170
|
app.use((err: Error, req: Request, resp: Response, next: NextFunction) => {
|
|
171
171
|
if (err instanceof CommercetoolsError) {
|
|
172
172
|
if (err.errors?.length > 0) {
|
|
173
|
-
|
|
173
|
+
resp.status(err.statusCode).send({
|
|
174
174
|
statusCode: err.statusCode,
|
|
175
175
|
message: err.message,
|
|
176
176
|
errors: err.errors,
|
|
177
177
|
});
|
|
178
|
+
return;
|
|
178
179
|
}
|
|
179
180
|
|
|
180
|
-
|
|
181
|
+
resp.status(err.statusCode).send({
|
|
181
182
|
statusCode: err.statusCode,
|
|
182
183
|
message: err.message,
|
|
183
184
|
errors: [err.info],
|
|
184
185
|
});
|
|
186
|
+
return;
|
|
185
187
|
}
|
|
186
188
|
console.error(err);
|
|
187
|
-
|
|
189
|
+
resp.status(500).send({
|
|
188
190
|
error: err.message,
|
|
189
191
|
});
|
|
192
|
+
return;
|
|
190
193
|
});
|
|
191
194
|
|
|
192
195
|
return app;
|
package/src/oauth/server.test.ts
CHANGED
|
@@ -39,6 +39,14 @@ describe("OAuth2Server", () => {
|
|
|
39
39
|
|
|
40
40
|
expect(response.status, JSON.stringify(body)).toBe(200);
|
|
41
41
|
expect(body).toHaveProperty("access_token");
|
|
42
|
+
expect(body).toEqual({
|
|
43
|
+
// scope: expect.stringMatching(/anonymous_id:([^\s]+)/),
|
|
44
|
+
scope: expect.any(String),
|
|
45
|
+
access_token: expect.stringMatching(/\S{8,}==$/),
|
|
46
|
+
refresh_token: expect.stringMatching(/my-project.*/),
|
|
47
|
+
expires_in: 172800,
|
|
48
|
+
token_type: "Bearer",
|
|
49
|
+
});
|
|
42
50
|
});
|
|
43
51
|
|
|
44
52
|
it("should failed on invalid refresh token", async () => {
|
package/src/oauth/server.ts
CHANGED
|
@@ -160,7 +160,7 @@ export class OAuth2Server {
|
|
|
160
160
|
);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
const grantType = request.query.grant_type || request.body
|
|
163
|
+
const grantType = request.query.grant_type || request.body?.grant_type;
|
|
164
164
|
if (!grantType) {
|
|
165
165
|
return next(
|
|
166
166
|
new CommercetoolsError<InvalidRequestError>(
|
|
@@ -179,11 +179,12 @@ export class OAuth2Server {
|
|
|
179
179
|
request.credentials.clientSecret,
|
|
180
180
|
request.query.scope?.toString(),
|
|
181
181
|
);
|
|
182
|
-
|
|
182
|
+
response.status(200).send(token);
|
|
183
|
+
return;
|
|
183
184
|
}
|
|
184
185
|
if (grantType === "refresh_token") {
|
|
185
186
|
const refreshToken =
|
|
186
|
-
request.query.refresh_token?.toString() || request.body
|
|
187
|
+
request.query.refresh_token?.toString() || request.body?.refresh_token;
|
|
187
188
|
if (!refreshToken) {
|
|
188
189
|
return next(
|
|
189
190
|
new CommercetoolsError<InvalidRequestError>(
|
|
@@ -214,7 +215,8 @@ export class OAuth2Server {
|
|
|
214
215
|
),
|
|
215
216
|
);
|
|
216
217
|
}
|
|
217
|
-
|
|
218
|
+
response.status(200).send(token);
|
|
219
|
+
return;
|
|
218
220
|
}
|
|
219
221
|
return next(
|
|
220
222
|
new CommercetoolsError<UnsupportedGrantType>(
|
|
@@ -233,7 +235,7 @@ export class OAuth2Server {
|
|
|
233
235
|
next: NextFunction,
|
|
234
236
|
) {
|
|
235
237
|
const projectKey = request.params.projectKey;
|
|
236
|
-
const grantType = request.query.grant_type || request.body
|
|
238
|
+
const grantType = request.query.grant_type || request.body?.grant_type;
|
|
237
239
|
if (!grantType) {
|
|
238
240
|
return next(
|
|
239
241
|
new CommercetoolsError<InvalidRequestError>(
|
|
@@ -247,12 +249,12 @@ export class OAuth2Server {
|
|
|
247
249
|
}
|
|
248
250
|
|
|
249
251
|
if (grantType === "password") {
|
|
250
|
-
const username = request.query.username || request.body
|
|
252
|
+
const username = request.query.username || request.body?.username;
|
|
251
253
|
const password = hashPassword(
|
|
252
254
|
request.query.password || request.body.password,
|
|
253
255
|
);
|
|
254
256
|
const scope =
|
|
255
|
-
request.query.scope?.toString() || request.body
|
|
257
|
+
request.query.scope?.toString() || request.body?.scope?.toString();
|
|
256
258
|
|
|
257
259
|
const result = this.customerRepository.query(
|
|
258
260
|
{ projectKey: request.params.projectKey },
|
|
@@ -275,7 +277,7 @@ export class OAuth2Server {
|
|
|
275
277
|
|
|
276
278
|
const customer = result.results[0];
|
|
277
279
|
const token = this.store.getCustomerToken(projectKey, customer.id, scope);
|
|
278
|
-
|
|
280
|
+
response.status(200).send(token);
|
|
279
281
|
}
|
|
280
282
|
}
|
|
281
283
|
|
|
@@ -328,7 +330,8 @@ export class OAuth2Server {
|
|
|
328
330
|
|
|
329
331
|
const customer = result.results[0];
|
|
330
332
|
const token = this.store.getCustomerToken(projectKey, customer.id, scope);
|
|
331
|
-
|
|
333
|
+
response.status(200).send(token);
|
|
334
|
+
return;
|
|
332
335
|
}
|
|
333
336
|
}
|
|
334
337
|
|
|
@@ -353,7 +356,7 @@ export class OAuth2Server {
|
|
|
353
356
|
|
|
354
357
|
if (grantType === "client_credentials") {
|
|
355
358
|
const scope =
|
|
356
|
-
request.query.scope?.toString() || request.body
|
|
359
|
+
request.query.scope?.toString() || request.body?.scope?.toString();
|
|
357
360
|
|
|
358
361
|
const anonymous_id = undefined;
|
|
359
362
|
|
|
@@ -362,7 +365,8 @@ export class OAuth2Server {
|
|
|
362
365
|
anonymous_id,
|
|
363
366
|
scope,
|
|
364
367
|
);
|
|
365
|
-
|
|
368
|
+
response.status(200).send(token);
|
|
369
|
+
return;
|
|
366
370
|
}
|
|
367
371
|
}
|
|
368
372
|
}
|
package/src/services/abstract.ts
CHANGED
|
@@ -64,15 +64,17 @@ export default abstract class AbstractService {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const result = this.repository.query(getRepositoryContext(request), params);
|
|
67
|
-
|
|
67
|
+
response.status(200).send(result);
|
|
68
|
+
return;
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
getWithId(request: Request, response: Response) {
|
|
71
72
|
const result = this._expandWithId(request, request.params.id);
|
|
72
73
|
if (!result) {
|
|
73
|
-
|
|
74
|
+
response.status(404).send();
|
|
75
|
+
return;
|
|
74
76
|
}
|
|
75
|
-
|
|
77
|
+
response.status(200).send(result);
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
getWithKey(request: Request, response: Response) {
|
|
@@ -83,8 +85,11 @@ export default abstract class AbstractService {
|
|
|
83
85
|
expand: this._parseParam(request.query.expand),
|
|
84
86
|
},
|
|
85
87
|
);
|
|
86
|
-
if (!result)
|
|
87
|
-
|
|
88
|
+
if (!result) {
|
|
89
|
+
response.status(404).send();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
response.status(200).send(result);
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
deleteWithId(request: Request, response: Response) {
|
|
@@ -96,9 +101,10 @@ export default abstract class AbstractService {
|
|
|
96
101
|
},
|
|
97
102
|
);
|
|
98
103
|
if (!result) {
|
|
99
|
-
|
|
104
|
+
response.status(404).send("Not found");
|
|
105
|
+
return;
|
|
100
106
|
}
|
|
101
|
-
|
|
107
|
+
response.status(200).send(result);
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
deleteWithKey(request: Request, response: Response) {
|
|
@@ -107,7 +113,8 @@ export default abstract class AbstractService {
|
|
|
107
113
|
request.params.key,
|
|
108
114
|
);
|
|
109
115
|
if (!resource) {
|
|
110
|
-
|
|
116
|
+
response.status(404).send("Not found");
|
|
117
|
+
return;
|
|
111
118
|
}
|
|
112
119
|
|
|
113
120
|
const result = this.repository.delete(
|
|
@@ -118,9 +125,10 @@ export default abstract class AbstractService {
|
|
|
118
125
|
},
|
|
119
126
|
);
|
|
120
127
|
if (!result) {
|
|
121
|
-
|
|
128
|
+
response.status(404).send("Not found");
|
|
129
|
+
return;
|
|
122
130
|
}
|
|
123
|
-
|
|
131
|
+
response.status(200).send(result);
|
|
124
132
|
}
|
|
125
133
|
|
|
126
134
|
post(request: Request, response: Response) {
|
|
@@ -130,7 +138,7 @@ export default abstract class AbstractService {
|
|
|
130
138
|
draft,
|
|
131
139
|
);
|
|
132
140
|
const result = this._expandWithId(request, resource.id);
|
|
133
|
-
|
|
141
|
+
response.status(this.createStatusCode).send(result);
|
|
134
142
|
}
|
|
135
143
|
|
|
136
144
|
postWithId(request: Request, response: Response) {
|
|
@@ -143,7 +151,8 @@ export default abstract class AbstractService {
|
|
|
143
151
|
request.params.id,
|
|
144
152
|
);
|
|
145
153
|
if (!resource) {
|
|
146
|
-
|
|
154
|
+
response.status(404).send("Not found");
|
|
155
|
+
return;
|
|
147
156
|
}
|
|
148
157
|
|
|
149
158
|
const updatedResource = this.repository.processUpdateActions(
|
|
@@ -154,7 +163,7 @@ export default abstract class AbstractService {
|
|
|
154
163
|
);
|
|
155
164
|
|
|
156
165
|
const result = this._expandWithId(request, updatedResource.id);
|
|
157
|
-
|
|
166
|
+
response.status(200).send(result);
|
|
158
167
|
}
|
|
159
168
|
|
|
160
169
|
postWithKey(request: Request, response: Response) {
|
|
@@ -168,7 +177,8 @@ export default abstract class AbstractService {
|
|
|
168
177
|
request.params.key,
|
|
169
178
|
);
|
|
170
179
|
if (!resource) {
|
|
171
|
-
|
|
180
|
+
response.status(404).send("Not found");
|
|
181
|
+
return;
|
|
172
182
|
}
|
|
173
183
|
|
|
174
184
|
const updatedResource = this.repository.processUpdateActions(
|
|
@@ -179,7 +189,7 @@ export default abstract class AbstractService {
|
|
|
179
189
|
);
|
|
180
190
|
|
|
181
191
|
const result = this._expandWithId(request, updatedResource.id);
|
|
182
|
-
|
|
192
|
+
response.status(200).send(result);
|
|
183
193
|
}
|
|
184
194
|
|
|
185
195
|
protected _expandWithId(request: Request, resourceId: string) {
|
package/src/services/cart.ts
CHANGED
|
@@ -38,7 +38,8 @@ export class CartService extends AbstractService {
|
|
|
38
38
|
: this.repository.get(context, request.body.reference.id);
|
|
39
39
|
|
|
40
40
|
if (!cartOrOrder) {
|
|
41
|
-
|
|
41
|
+
response.status(400).send();
|
|
42
|
+
return;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
const cartDraft: CartDraft = {
|
|
@@ -55,6 +56,6 @@ export class CartService extends AbstractService {
|
|
|
55
56
|
|
|
56
57
|
const newCart = this.repository.create(context, cartDraft);
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
response.status(200).send(newCart);
|
|
59
60
|
}
|
|
60
61
|
}
|
|
@@ -41,7 +41,7 @@ export class CustomObjectService extends AbstractService {
|
|
|
41
41
|
},
|
|
42
42
|
);
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
response.status(200).send(result);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
getWithContainerAndKey(request: Request, response: Response) {
|
|
@@ -52,9 +52,10 @@ export class CustomObjectService extends AbstractService {
|
|
|
52
52
|
);
|
|
53
53
|
|
|
54
54
|
if (!result) {
|
|
55
|
-
|
|
55
|
+
response.status(404).send("Not Found");
|
|
56
|
+
return;
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
+
response.status(200).send(result);
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
createWithContainerAndKey(request: Request, response: Response) {
|
|
@@ -65,7 +66,7 @@ export class CustomObjectService extends AbstractService {
|
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
const result = this.repository.create(getRepositoryContext(request), draft);
|
|
68
|
-
|
|
69
|
+
response.status(200).send(result);
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
deleteWithContainerAndKey(request: Request, response: Response) {
|
|
@@ -76,7 +77,8 @@ export class CustomObjectService extends AbstractService {
|
|
|
76
77
|
);
|
|
77
78
|
|
|
78
79
|
if (!current) {
|
|
79
|
-
|
|
80
|
+
response.status(404).send("Not Found");
|
|
81
|
+
return;
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
const result = this.repository.delete(
|
|
@@ -84,6 +86,6 @@ export class CustomObjectService extends AbstractService {
|
|
|
84
86
|
current.id,
|
|
85
87
|
);
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
response.status(200).send(result);
|
|
88
90
|
}
|
|
89
91
|
}
|
package/src/services/customer.ts
CHANGED
|
@@ -34,7 +34,7 @@ export class CustomerService extends AbstractService {
|
|
|
34
34
|
const result: CustomerSignInResult = {
|
|
35
35
|
customer: expanded,
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
response.status(this.createStatusCode).send(result);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
passwordResetToken(request: Request, response: Response) {
|
|
@@ -43,7 +43,7 @@ export class CustomerService extends AbstractService {
|
|
|
43
43
|
request.body,
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
response.status(200).send(customer);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
passwordReset(request: Request, response: Response) {
|
|
@@ -52,7 +52,7 @@ export class CustomerService extends AbstractService {
|
|
|
52
52
|
request.body,
|
|
53
53
|
);
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
response.status(200).send(customer);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
confirmEmailToken(request: Request, response: Response) {
|
|
@@ -61,6 +61,6 @@ export class CustomerService extends AbstractService {
|
|
|
61
61
|
getRepositoryContext(request),
|
|
62
62
|
id,
|
|
63
63
|
);
|
|
64
|
-
|
|
64
|
+
response.status(200).send(token);
|
|
65
65
|
}
|
|
66
66
|
}
|
package/src/services/my-cart.ts
CHANGED
|
@@ -37,8 +37,9 @@ export class MyCartService extends AbstractService {
|
|
|
37
37
|
activeCart(request: Request, response: Response) {
|
|
38
38
|
const resource = this.repository.getActiveCart(request.params.projectKey);
|
|
39
39
|
if (!resource) {
|
|
40
|
-
|
|
40
|
+
response.status(404).send("Not found");
|
|
41
|
+
return;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
response.status(200).send(resource);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -44,16 +44,18 @@ export class MyCustomerService extends AbstractService {
|
|
|
44
44
|
getMe(request: Request, response: Response) {
|
|
45
45
|
const resource = this.repository.getMe(getRepositoryContext(request));
|
|
46
46
|
if (!resource) {
|
|
47
|
-
|
|
47
|
+
response.status(404).send("Not found");
|
|
48
|
+
return;
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
+
response.status(200).send(resource);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
updateMe(request: Request, response: Response) {
|
|
53
54
|
const resource = this.repository.getMe(getRepositoryContext(request));
|
|
54
55
|
|
|
55
56
|
if (!resource) {
|
|
56
|
-
|
|
57
|
+
response.status(404).send("Not found");
|
|
58
|
+
return;
|
|
57
59
|
}
|
|
58
60
|
const updateRequest = validateData<Update>(
|
|
59
61
|
request.body,
|
|
@@ -67,16 +69,17 @@ export class MyCustomerService extends AbstractService {
|
|
|
67
69
|
);
|
|
68
70
|
|
|
69
71
|
const result = this._expandWithId(request, updatedResource.id);
|
|
70
|
-
|
|
72
|
+
response.status(200).send(result);
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
deleteMe(request: Request, response: Response) {
|
|
74
76
|
const resource = this.repository.deleteMe(getRepositoryContext(request));
|
|
75
77
|
if (!resource) {
|
|
76
|
-
|
|
78
|
+
response.status(404).send("Not found");
|
|
79
|
+
return;
|
|
77
80
|
}
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
response.status(200).send(resource);
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
signUp(request: Request, response: Response) {
|
|
@@ -86,7 +89,7 @@ export class MyCustomerService extends AbstractService {
|
|
|
86
89
|
draft,
|
|
87
90
|
);
|
|
88
91
|
const result = this._expandWithId(request, resource.id);
|
|
89
|
-
|
|
92
|
+
response.status(this.createStatusCode).send({ customer: result });
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
changePassword(request: Request, response: Response) {
|
|
@@ -95,7 +98,7 @@ export class MyCustomerService extends AbstractService {
|
|
|
95
98
|
request.body,
|
|
96
99
|
);
|
|
97
100
|
|
|
98
|
-
|
|
101
|
+
response.status(200).send(customer);
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
resetPassword(request: Request, response: Response) {
|
|
@@ -104,7 +107,7 @@ export class MyCustomerService extends AbstractService {
|
|
|
104
107
|
request.body,
|
|
105
108
|
);
|
|
106
109
|
|
|
107
|
-
|
|
110
|
+
response.status(200).send(customer);
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
emailConfirm(request: Request, response: Response) {
|
|
@@ -113,7 +116,7 @@ export class MyCustomerService extends AbstractService {
|
|
|
113
116
|
request.body,
|
|
114
117
|
);
|
|
115
118
|
|
|
116
|
-
|
|
119
|
+
response.status(200).send(customer);
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
signIn(request: Request, response: Response) {
|
|
@@ -125,7 +128,7 @@ export class MyCustomerService extends AbstractService {
|
|
|
125
128
|
});
|
|
126
129
|
|
|
127
130
|
if (result.count === 0) {
|
|
128
|
-
|
|
131
|
+
response.status(400).send({
|
|
129
132
|
message: "Account with the given credentials not found.",
|
|
130
133
|
errors: [
|
|
131
134
|
{
|
|
@@ -134,8 +137,9 @@ export class MyCustomerService extends AbstractService {
|
|
|
134
137
|
},
|
|
135
138
|
],
|
|
136
139
|
});
|
|
140
|
+
return;
|
|
137
141
|
}
|
|
138
142
|
|
|
139
|
-
|
|
143
|
+
response.status(200).send({ customer: result.results[0] });
|
|
140
144
|
}
|
|
141
145
|
}
|
package/src/services/order.ts
CHANGED
|
@@ -29,7 +29,7 @@ export class OrderService extends AbstractService {
|
|
|
29
29
|
getRepositoryContext(request),
|
|
30
30
|
importDraft,
|
|
31
31
|
);
|
|
32
|
-
|
|
32
|
+
response.status(200).send(resource);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
getWithOrderNumber(request: Request, response: Response) {
|
|
@@ -41,8 +41,9 @@ export class OrderService extends AbstractService {
|
|
|
41
41
|
request.query,
|
|
42
42
|
);
|
|
43
43
|
if (resource) {
|
|
44
|
-
|
|
44
|
+
response.status(200).send(resource);
|
|
45
|
+
return;
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
+
response.status(404).send("Not found");
|
|
47
48
|
}
|
|
48
49
|
}
|
|
@@ -34,7 +34,7 @@ export class ProductProjectionService extends AbstractService {
|
|
|
34
34
|
limit: limit !== undefined ? Number(limit) : undefined,
|
|
35
35
|
offset: offset !== undefined ? Number(offset) : undefined,
|
|
36
36
|
});
|
|
37
|
-
|
|
37
|
+
response.status(200).send(result);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
search(request: Request, response: Response) {
|
|
@@ -58,6 +58,6 @@ export class ProductProjectionService extends AbstractService {
|
|
|
58
58
|
getRepositoryContext(request),
|
|
59
59
|
searchParams,
|
|
60
60
|
);
|
|
61
|
-
|
|
61
|
+
response.status(200).send(resource);
|
|
62
62
|
}
|
|
63
63
|
}
|
package/src/services/product.ts
CHANGED
package/src/services/project.ts
CHANGED
|
@@ -20,7 +20,7 @@ export class ProjectService {
|
|
|
20
20
|
|
|
21
21
|
get(request: Request, response: Response) {
|
|
22
22
|
const project = this.repository.get(getRepositoryContext(request));
|
|
23
|
-
|
|
23
|
+
response.status(200).send(project);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
post(request: Request, response: Response) {
|
|
@@ -31,7 +31,8 @@ export class ProjectService {
|
|
|
31
31
|
const project = this.repository.get(getRepositoryContext(request));
|
|
32
32
|
|
|
33
33
|
if (!project) {
|
|
34
|
-
|
|
34
|
+
response.status(404).send({});
|
|
35
|
+
return;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
const updatedResource = this.repository.processUpdateActions(
|
|
@@ -41,6 +42,6 @@ export class ProjectService {
|
|
|
41
42
|
updateRequest.actions,
|
|
42
43
|
);
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
response.status(200).send(updatedResource);
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -24,7 +24,8 @@ export class ShippingMethodService extends AbstractService {
|
|
|
24
24
|
matchingCart(request: Request, response: Response) {
|
|
25
25
|
const cartId = queryParamsValue(request.query.cartId);
|
|
26
26
|
if (!cartId) {
|
|
27
|
-
|
|
27
|
+
response.status(400).send();
|
|
28
|
+
return;
|
|
28
29
|
}
|
|
29
30
|
const result = this.repository.matchingCart(
|
|
30
31
|
getRepositoryContext(request),
|
|
@@ -33,6 +34,7 @@ export class ShippingMethodService extends AbstractService {
|
|
|
33
34
|
expand: this._parseParam(request.query.expand),
|
|
34
35
|
},
|
|
35
36
|
);
|
|
36
|
-
|
|
37
|
+
response.status(200).send(result);
|
|
38
|
+
return;
|
|
37
39
|
}
|
|
38
40
|
}
|