Skip to content

Commit d90985d

Browse files
authored
Merge pull request #23 from piyook/chore/update-deps-and-add-zod
chore(): update deps and add zod
2 parents 43b736b + eccbb9b commit d90985d

File tree

16 files changed

+320
-631
lines changed

16 files changed

+320
-631
lines changed

.husky/pre-push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
npx validate-branch-name
1+
npm run validate-branch-name
22
npm run pretty
33
npm run lint
44
npm run test:e2e

cypress/e2e/lambda-endpoint-spec.cy.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ describe('Lambda demo endpoint works as expected', () => {
2626
});
2727
});
2828

29-
it('check test Lambda function error handling is working with no body data', () => {
29+
it('check test Lambda function error handling is working with no userQuestion in request body data', () => {
3030
cy.request({
3131
method: 'POST',
3232
url: '/api/lambda',
33+
body: {},
3334
failOnStatusCode: false,
3435
}).then((response) => {
3536
expect(response.status).to.eq(500);
@@ -38,4 +39,17 @@ describe('Lambda demo endpoint works as expected', () => {
3839
);
3940
});
4041
});
42+
43+
it('check test Lambda function error handling is working with no body object in request', () => {
44+
cy.request({
45+
method: 'POST',
46+
url: '/api/lambda',
47+
failOnStatusCode: false,
48+
}).then((response) => {
49+
expect(response.status).to.eq(500);
50+
expect(response.body).to.contain(
51+
'Invalid Payload : must contain a body property',
52+
);
53+
});
54+
});
4155
});

package-lock.json

Lines changed: 237 additions & 584 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,35 @@
1414
"pretty-fix": "prettier 'src/**/*.{js,jsx,ts,tsx,css,scss,md}' --write",
1515
"test:e2e": "start-server-and-test dev tcp:8000 cypress:run",
1616
"cypress:open": "cypress open",
17-
"cypress:run": "cypress run --e2e"
17+
"cypress:run": "cypress run --e2e",
18+
"validate-branch-name": "bash validate-branch-name.sh"
1819
},
1920
"dependencies": {
20-
"@faker-js/faker": "^9.0.1",
21+
"@faker-js/faker": "^9.3.0",
2122
"@mswjs/data": "^0.16.2",
22-
"@mswjs/http-middleware": "^0.10.1",
23+
"@mswjs/http-middleware": "^0.10.2",
2324
"@types/chai-json-schema": "^1.4.10",
24-
"@types/express": "^4.17.21",
25+
"@types/express": "^5.0.0",
2526
"@types/markdown-it": "^14.1.2",
2627
"chai-json-schema": "^1.5.1",
27-
"dotenv": "^16.4.5",
28+
"dotenv": "^16.4.6",
2829
"highlight.js": "^11.10.0",
2930
"markdown-it": "^14.1.0",
30-
"msw": "^2.4.7",
31-
"tsx": "^4.19.1",
32-
"typescript": "^5.6.2"
31+
"msw": "^2.6.6",
32+
"tsx": "^4.19.2",
33+
"typescript": "^5.7.2",
34+
"zod": "^3.23.8"
3335
},
3436
"devDependencies": {
35-
"@commitlint/cli": "^19.5.0",
36-
"@commitlint/config-conventional": "^19.5.0",
37-
"@types/aws-lambda": "^8.10.145",
38-
"@types/node": "^22.5.5",
39-
"cypress": "^13.14.2",
40-
"husky": "^9.1.6",
37+
"@commitlint/cli": "^19.6.0",
38+
"@commitlint/config-conventional": "^19.6.0",
39+
"@types/aws-lambda": "^8.10.146",
40+
"@types/node": "^22.10.1",
41+
"cypress": "^13.16.0",
42+
"husky": "^9.1.7",
4143
"lint-staged": "^15.2.10",
42-
"prettier": "3.3.3",
44+
"prettier": "3.4.1",
4345
"start-server-and-test": "^2.0.8",
44-
"validate-branch-name": "^1.3.1",
4546
"xo": "^0.59.3"
4647
},
4748
"lint-staged": {
@@ -52,9 +53,5 @@
5253
"extends": [
5354
"@commitlint/config-conventional"
5455
]
55-
},
56-
"validate-branch-name": {
57-
"pattern": "^(main|dev){1}$|^(feat|fix|hotfix|release|chore)/.+$",
58-
"errorMsg": "INVALID BRANCH NAME: use format 'feat|fix|hotfix|release|core/your-branch-name'"
5956
}
6057
}

src/api/bikes/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { http, HttpResponse } from 'msw';
33
// Add any http handler here (get, push , delete etc., and middleware as needed)
44

55
function handler(pathName: string) {
6+
console.log('bikes path');
67
return [
78
http.get(`/${pathName}`, ({ request }) => {
89
const url = new URL(request.url);

src/api/lambda/api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ function handler(pathName: string) {
1818
// Make POST requests to this route with the JSON body data with {"userQuestion": "some test text"} to test
1919
http.post(`/${pathName}`, async ({ request }) => {
2020
const event = await requestToApiGatewayProxyEvent(request);
21-
2221
return HttpResponse.json(await demoHandler(event));
2322
}),
2423
];

src/api/posts/api.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { db } from '../../models/db.js';
2+
import { prefix } from '../../utilities/env.js';
23

34
// Example of msw data auto REST handler generation
45
function handler(pathName: string) {
56
// Need to add a prefix here for automatic REST handler generation to a specific path
6-
const prefix = process.env?.USE_API_URL_PREFIX
7-
? '/' + process.env.USE_API_URL_PREFIX
8-
: '';
97
return [...db.post.toHandlers('rest', prefix)];
108
}
119

src/api/users/api.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { db } from '../../models/db.js';
2+
import { prefix } from '../../utilities/env.js';
23

34
// Example of msw data auto REST handler generation
45
function handler(pathName: string) {
56
// Need to add a prefix here for automatic REST handler generation to a specific path
6-
const prefix = process.env?.USE_API_URL_PREFIX
7-
? '/' + process.env.USE_API_URL_PREFIX
8-
: '';
97
return [...db.user.toHandlers('rest', prefix)];
108
}
119

src/lambdas/test-lambda.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const handler = async (
1212
): Promise<APIGatewayProxyResult> => {
1313
// On aws its JSON.parse (event.body) to get the body as an object
1414

15-
if (!event.body) {
15+
if (!event?.body) {
1616
throw new Error('Invalid Payload : must contain a body property');
1717
}
1818

src/server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ import { createServer } from '@mswjs/http-middleware';
33
import * as seeders from './seeders/index.js';
44
import getApiPaths from './utilities/file-scan.js';
55
import serverPage from './utilities/server-page.js';
6+
import { env } from './utilities/env.js';
67

78
const { apiHandlers, apiPaths } = await getApiPaths();
89

9-
const httpServer = createServer(...apiHandlers, ...serverPage(apiPaths));
10+
const httpServer = createServer({}, ...apiHandlers, ...serverPage(apiPaths));
1011

11-
httpServer.listen(process.env.SERVER_PORT);
12+
httpServer.listen(env.SERVER_PORT);
1213

1314
// Execute dB seeder functions
1415
for (const seeder of Object.values(seeders)) {
1516
seeder();
1617
}
1718

18-
console.log(`SERVER UP AND RUNNING ON LOCALHOST:${process.env.SERVER_PORT}`);
19+
console.log(`SERVER UP AND RUNNING ON LOCALHOST:${env.SERVER_PORT}`);

0 commit comments

Comments
 (0)