Skip to content

Commit 0532390

Browse files
committed
chore(): move to tab indents
1 parent 05d1036 commit 0532390

File tree

25 files changed

+466
-466
lines changed

25 files changed

+466
-466
lines changed

.prettierrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"singleQuote": true,
33
"tabWidth": 4,
4-
"useTabs": false,
4+
"useTabs": true,
55
"bracketSpacing": true
6-
}
6+
}

src/api/bikes/api.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,40 @@ import logger from '../../utilities/logger';
44
// Add any http handler here (get, push , delete etc., and middleware as needed)
55

66
function handler(pathName: string) {
7-
return [
8-
http.get(`/${pathName}`, ({ request }) => {
9-
const url = new URL(request.url);
10-
const type = url.searchParams.get('type');
11-
console.log(`starting ${pathName}`);
12-
console.log('Item Type is', type);
7+
return [
8+
http.get(`/${pathName}`, ({ request }) => {
9+
const url = new URL(request.url);
10+
const type = url.searchParams.get('type');
11+
console.log(`starting ${pathName}`);
12+
console.log('Item Type is', type);
1313

14-
// Log the request passing the request data, pathName and request type to the logger function
15-
logger({
16-
data: { type },
17-
pathName,
18-
type: 'GET',
19-
});
14+
// Log the request passing the request data, pathName and request type to the logger function
15+
logger({
16+
data: { type },
17+
pathName,
18+
type: 'GET',
19+
});
2020

21-
return HttpResponse.json({
22-
response: `this is a GET test response from ${pathName} for bike type: ${type ?? 'none'}`,
23-
});
24-
}),
25-
http.post(`/${pathName}`, async ({ request }) => {
26-
// Get Body Data using json(), text() or formData() depending on what is sent
27-
const bodyData = await request.json();
21+
return HttpResponse.json({
22+
response: `this is a GET test response from ${pathName} for bike type: ${type ?? 'none'}`,
23+
});
24+
}),
25+
http.post(`/${pathName}`, async ({ request }) => {
26+
// Get Body Data using json(), text() or formData() depending on what is sent
27+
const bodyData = await request.json();
2828

29-
// Log the request passing the request data, pathName and extra information to the logger function
30-
logger({
31-
data: bodyData,
32-
type: 'POST',
33-
pathName,
34-
});
29+
// Log the request passing the request data, pathName and extra information to the logger function
30+
logger({
31+
data: bodyData,
32+
type: 'POST',
33+
pathName,
34+
});
3535

36-
return HttpResponse.json({
37-
response: `this is a POST test response from ${pathName} with bodyData ${JSON.stringify(bodyData)}`,
38-
});
39-
}),
40-
];
36+
return HttpResponse.json({
37+
response: `this is a POST test response from ${pathName} with bodyData ${JSON.stringify(bodyData)}`,
38+
});
39+
}),
40+
];
4141
}
4242

4343
export default handler;

src/api/cats/api.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,37 @@ import { http, HttpResponse } from 'msw';
22
import { db } from '../../models/db.js';
33

44
function handler(pathName: string) {
5-
return [
6-
// Get all cats
7-
http.get(`/${pathName}`, ({ request }) => {
8-
const url = new URL(request.url);
9-
const type = url.searchParams.get('type');
10-
console.log(`starting ${pathName}`);
11-
console.log('Item Type is', type);
5+
return [
6+
// Get all cats
7+
http.get(`/${pathName}`, ({ request }) => {
8+
const url = new URL(request.url);
9+
const type = url.searchParams.get('type');
10+
console.log(`starting ${pathName}`);
11+
console.log('Item Type is', type);
1212

13-
const cats = db.cat.getAll();
14-
return HttpResponse.json(cats);
15-
}),
16-
// Get cat by id
17-
http.get(`/${pathName}/:id`, ({ params }) => {
18-
const id = params.id;
13+
const cats = db.cat.getAll();
14+
return HttpResponse.json(cats);
15+
}),
16+
// Get cat by id
17+
http.get(`/${pathName}/:id`, ({ params }) => {
18+
const id = params.id;
1919

20-
if (id) {
21-
console.log(`starting ${pathName}/${id.toString()}`);
20+
if (id) {
21+
console.log(`starting ${pathName}/${id.toString()}`);
2222

23-
const cats = db.cat.findFirst({
24-
where: {
25-
id: {
26-
equals: Number(id),
27-
},
28-
},
29-
});
30-
return HttpResponse.json(cats);
31-
}
23+
const cats = db.cat.findFirst({
24+
where: {
25+
id: {
26+
equals: Number(id),
27+
},
28+
},
29+
});
30+
return HttpResponse.json(cats);
31+
}
3232

33-
return HttpResponse.error();
34-
}),
35-
];
33+
return HttpResponse.error();
34+
}),
35+
];
3636
}
3737

3838
export default handler;

src/api/error/api.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import { http, HttpResponse } from 'msw';
22

33
function handler(pathName: string) {
4-
return [
5-
http.get(`/${pathName}`, ({ request }) => {
6-
const url = new URL(request.url);
4+
return [
5+
http.get(`/${pathName}`, ({ request }) => {
6+
const url = new URL(request.url);
77

8-
const statusCode = Number.parseInt(
9-
url.searchParams.get('status') ?? '404',
10-
10,
11-
);
8+
const statusCode = Number.parseInt(
9+
url.searchParams.get('status') ?? '404',
10+
10,
11+
);
1212

13-
const errorMessage = url.searchParams.get('message') ?? 'Not Found';
13+
const errorMessage = url.searchParams.get('message') ?? 'Not Found';
1414

15-
return HttpResponse.json(
16-
{ error: statusCode + ': ' + errorMessage },
17-
{ status: statusCode },
18-
);
19-
}),
20-
];
15+
return HttpResponse.json(
16+
{ error: statusCode + ': ' + errorMessage },
17+
{ status: statusCode },
18+
);
19+
}),
20+
];
2121
}
2222

2323
export default handler;

src/api/images/api.ts

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,69 +6,69 @@ import sharp from 'sharp';
66
// Add any http handler here (get, push , delete etc., and middleware as needed)
77

88
function handler(pathName: string) {
9-
return [
10-
http.get(`/${pathName}`, () => {
11-
return HttpResponse.text(
12-
`<body style="background-color: #383838; color:white">
9+
return [
10+
http.get(`/${pathName}`, () => {
11+
return HttpResponse.text(
12+
`<body style="background-color: #383838; color:white">
1313
<div style="text-align:center; padding:50px 0px 0px 0px">
1414
<h4>Access images stored in the src/resources/images folder using the format: <span style="color:red">api/images/{filename}</span></h4>
1515
<h4>Example: api/images/placeholder.png</h4>
1616
</div>
1717
</body>
1818
`,
19-
{
20-
headers: {
21-
'Content-Type': 'text/html',
22-
'Access-Control-Allow-Origin': '*',
23-
},
24-
},
25-
);
26-
}),
27-
http.get(`/${pathName}/:imageID`, async ({ request }) => {
28-
const url = new URL(request.url);
29-
const width = url.searchParams.get('width');
30-
const height = url.searchParams.get('height');
31-
console.log(`height ${height} and width ${width}`);
32-
const params = url.pathname.split('/').pop();
19+
{
20+
headers: {
21+
'Content-Type': 'text/html',
22+
'Access-Control-Allow-Origin': '*',
23+
},
24+
},
25+
);
26+
}),
27+
http.get(`/${pathName}/:imageID`, async ({ request }) => {
28+
const url = new URL(request.url);
29+
const width = url.searchParams.get('width');
30+
const height = url.searchParams.get('height');
31+
console.log(`height ${height} and width ${width}`);
32+
const params = url.pathname.split('/').pop();
3333

34-
console.log(`starting ${pathName}`);
34+
console.log(`starting ${pathName}`);
3535

36-
try {
37-
// Convert width and height to integers, if provided
38-
const resizeOptions: sharp.ResizeOptions = {};
39-
if (width && height)
40-
resizeOptions.width = Number.parseInt(width, 10);
41-
if (height && width)
42-
resizeOptions.height = Number.parseInt(height, 10);
36+
try {
37+
// Convert width and height to integers, if provided
38+
const resizeOptions: sharp.ResizeOptions = {};
39+
if (width && height)
40+
resizeOptions.width = Number.parseInt(width, 10);
41+
if (height && width)
42+
resizeOptions.height = Number.parseInt(height, 10);
4343

44-
const inputBuffer = fs.readFileSync(
45-
path.resolve(`./src/resources/images/${params}`),
46-
);
47-
const resizedImageBuffer = await sharp(inputBuffer)
48-
.resize(resizeOptions) // Only applies resize if width/height are present
49-
.png()
50-
.toBuffer();
44+
const inputBuffer = fs.readFileSync(
45+
path.resolve(`./src/resources/images/${params}`),
46+
);
47+
const resizedImageBuffer = await sharp(inputBuffer)
48+
.resize(resizeOptions) // Only applies resize if width/height are present
49+
.png()
50+
.toBuffer();
5151

52-
return HttpResponse.arrayBuffer(resizedImageBuffer, {
53-
headers: {
54-
'Content-Type': 'image/png',
55-
'Access-Control-Allow-Origin': '*',
56-
},
57-
});
58-
} catch {
59-
return HttpResponse.text(
60-
'Error: File not found. Check file is in the src/resources/images folder',
61-
{
62-
status: 404,
63-
headers: {
64-
'Content-Type': 'text/html',
65-
'Access-Control-Allow-Origin': '*',
66-
},
67-
},
68-
);
69-
}
70-
}),
71-
];
52+
return HttpResponse.arrayBuffer(resizedImageBuffer, {
53+
headers: {
54+
'Content-Type': 'image/png',
55+
'Access-Control-Allow-Origin': '*',
56+
},
57+
});
58+
} catch {
59+
return HttpResponse.text(
60+
'Error: File not found. Check file is in the src/resources/images folder',
61+
{
62+
status: 404,
63+
headers: {
64+
'Content-Type': 'text/html',
65+
'Access-Control-Allow-Origin': '*',
66+
},
67+
},
68+
);
69+
}
70+
}),
71+
];
7272
}
7373

7474
export default handler;

0 commit comments

Comments
 (0)