Skip to content

Commit 9e2a9ef

Browse files
committed
fix: conflicts
2 parents 443026e + 7e524a5 commit 9e2a9ef

File tree

6 files changed

+55
-15
lines changed

6 files changed

+55
-15
lines changed

@types/fastify/fastify.d.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Auth } from "../../src/schemas/auth.ts";
1+
import { Auth } from '../../src/schemas/auth.ts'
22

3-
declare module "fastify" {
4-
export interface FastifyRequest {
5-
user: Auth
6-
}
3+
declare module 'fastify' {
4+
export interface FastifyRequest {
5+
user: Auth
6+
}
77
}

@types/node/environment.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ declare global {
1313
}
1414
}
1515

16-
export {};
16+
export {}

package.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,12 @@
4949
"react-dom": "^18.3.1"
5050
},
5151
"devDependencies": {
52-
"@types/node": "^22.0.0",
53-
"@types/react": "^18.3.4",
54-
"@types/react-dom": "^18.3.0",
55-
"eslint": "^9.4.0",
52+
"@types/node": "^22.5.5",
53+
"eslint": "^9.11.0",
5654
"fastify-tsconfig": "^2.0.0",
57-
"mysql2": "^3.10.1",
55+
"mysql2": "^3.11.3",
5856
"neostandard": "^0.11.5",
5957
"tap": "^21.0.1",
60-
"typescript": "^5.4.5"
58+
"typescript": "^5.6.2"
6159
}
6260
}

src/app.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ export default async function serviceApp (
6060
'Unhandled error occurred'
6161
)
6262

63-
const statusCode = err.statusCode ?? 500
64-
reply.code(statusCode)
63+
reply.code(err.statusCode ?? 500)
6564

66-
return { message: 'Internal Server Error' }
65+
let message = 'Internal Server Error'
66+
if (err.statusCode === 401) {
67+
message = err.message
68+
}
69+
70+
return { message }
6771
})
6872

6973
// An attacker could search for valid URLs if your 404 error handling is not rate limited.

src/routes/home.ts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {
2+
FastifyPluginAsyncTypebox,
3+
Type
4+
} from '@fastify/type-provider-typebox'
5+
6+
const plugin: FastifyPluginAsyncTypebox = async (fastify) => {
7+
fastify.get(
8+
'/',
9+
{
10+
schema: {
11+
response: {
12+
200: Type.Object({
13+
message: Type.String()
14+
})
15+
}
16+
}
17+
},
18+
async function () {
19+
return { message: 'Welcome to the official fastify demo!' }
20+
}
21+
)
22+
}
23+
24+
export default plugin

test/routes/home.test.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { test } from 'node:test'
2+
import assert from 'node:assert'
3+
import { build } from '../helper.js'
4+
5+
test('GET /', async (t) => {
6+
const app = await build(t)
7+
const res = await app.inject({
8+
url: '/'
9+
})
10+
11+
assert.deepStrictEqual(JSON.parse(res.payload), {
12+
message: 'Welcome to the official fastify demo!'
13+
})
14+
})

0 commit comments

Comments
 (0)