Skip to content

Commit e4b95c7

Browse files
committed
chore(npm): update dependencies
1 parent 935f517 commit e4b95c7

12 files changed

Lines changed: 391 additions & 370 deletions

File tree

package-lock.json

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

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@athenna/http",
3-
"version": "5.8.0",
3+
"version": "5.9.0",
44
"description": "The Athenna Http server. Built on top of fastify.",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",
@@ -75,19 +75,19 @@
7575
},
7676
"devDependencies": {
7777
"@athenna/artisan": "^5.3.0",
78-
"@athenna/common": "^5.3.0",
78+
"@athenna/common": "^5.4.0",
7979
"@athenna/config": "^5.1.0",
8080
"@athenna/ioc": "^5.0.0",
8181
"@athenna/logger": "^5.1.0",
8282
"@athenna/test": "^5.2.0",
8383
"@athenna/tsconfig": "^5.0.0",
8484
"@athenna/view": "^5.1.0",
85-
"@fastify/cors": "^8.5.0",
86-
"@fastify/helmet": "^11.1.1",
87-
"@fastify/rate-limit": "^8.1.1",
88-
"@fastify/static": "^7.0.4",
89-
"@fastify/swagger": "^8.15.0",
90-
"@fastify/swagger-ui": "^3.1.0",
85+
"@fastify/cors": "^10.0.1",
86+
"@fastify/helmet": "^13.0.0",
87+
"@fastify/rate-limit": "^10.2.1",
88+
"@fastify/static": "^8.0.3",
89+
"@fastify/swagger": "^9.4.0",
90+
"@fastify/swagger-ui": "^5.2.0",
9191
"@fastify/vite": "^7.0.1",
9292
"@typescript-eslint/eslint-plugin": "^7.18.0",
9393
"@typescript-eslint/parser": "^7.18.0",

src/context/Response.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ export class Response {
322322
*/
323323
public async redirectTo(url: string, status?: number): Promise<Response> {
324324
if (status) {
325-
await this.response.redirect(status, url)
325+
await this.response.redirect(url, status)
326326

327327
return this
328328
}

src/handlers/HttpExceptionHandler.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ export class HttpExceptionHandler {
3030
* The exception handler of all request handlers.
3131
*/
3232
public async handle({ error, response }: ErrorContext): Promise<void> {
33+
let code = error.code
34+
35+
if (error.code === undefined) {
36+
code = error.name || 'E_INTERNAL_SERVER'
37+
}
38+
3339
const body: any = {
3440
statusCode: Json.copy(error.statusCode) || Json.copy(error.status) || 500,
35-
code: String.toSnakeCase(
36-
`${error.code}` || error.name || 'E_INTERNAL_SERVER'
37-
).toUpperCase(),
41+
code: String.toSnakeCase(code).toUpperCase(),
3842
name: Json.copy(error.name),
3943
message: Json.copy(error.message),
4044
details: Json.copy(error.details),

src/providers/HttpServerProvider.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import { ServerImpl } from '#src/server/ServerImpl'
1212

1313
export class HttpServerProvider extends ServiceProvider {
1414
public register() {
15-
this.container.instance('Athenna/Core/HttpServer', new ServerImpl())
15+
this.container.instance(
16+
'Athenna/Core/HttpServer',
17+
new ServerImpl(Config.get('http.fastify'))
18+
)
1619
}
1720

1821
public async shutdown() {

src/server/ServerImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class ServerImpl {
4545
public isListening: boolean
4646

4747
public constructor(options?: FastifyServerOptions) {
48-
this.fastify = fastify.fastify(options)
48+
this.fastify = fastify.fastify({ ...options, exposeHeadRoutes: false })
4949
this.isListening = false
5050

5151
this.fastify.decorateReply('body', null)

tests/unit/commands/RouteListCommandTest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export default class RouteListCommandTest extends BaseCommandTest {
1515
public async shouldBeAbleToListAllRoutesRegisteredInTheHttpServer({ command }: Context) {
1616
const output = await command.run('route:list')
1717

18+
console.log(output.output)
19+
1820
output.assertSucceeded()
1921
output.assertLogged('[ LISTING ROUTES ]')
2022
output.assertLogged('GET|HEAD')

tests/unit/context/RequestTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default class RequestTest {
4646
public async shouldBeAbleToGetTheRequestHostname({ assert }: Context) {
4747
const ctx = { request: new Request(this.request) }
4848

49-
assert.equal(ctx.request.hostname, 'localhost:80')
49+
assert.equal(ctx.request.hostname, 'localhost')
5050
}
5151

5252
@Test()

tests/unit/kernels/HttpKernelTest.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export default class HttpKernelTest {
3939

4040
assert.deepEqual(response.json(), { hello: true })
4141
assert.containsSubset(response.headers, {
42-
vary: 'Origin',
4342
'access-control-expose-headers': '*'
4443
})
4544
assert.isTrue(Server.fastify.hasPlugin('@fastify/cors'))
@@ -55,11 +54,9 @@ export default class HttpKernelTest {
5554

5655
assert.deepEqual(response.json(), { hello: true })
5756
assert.containsSubset(response.headers, {
58-
'x-frame-options': 'SAMEORIGIN',
59-
'x-dns-prefetch-control': 'off',
60-
'cross-origin-opener-policy': 'same-origin',
61-
'cross-origin-resource-policy': 'same-origin',
62-
'strict-transport-security': 'max-age=15552000; includeSubDomains'
57+
'x-content-type-options': 'nosniff',
58+
'x-download-options': 'noopen',
59+
'x-xss-protection': '0'
6360
})
6461
assert.isTrue(Server.fastify.hasPlugin('@fastify/helmet'))
6562
}
@@ -71,7 +68,7 @@ export default class HttpKernelTest {
7168

7269
const response = await Server.request().get('documentation')
7370

74-
assert.equal(response.statusCode, 302)
71+
assert.equal(response.statusCode, 200)
7572
assert.isTrue(Server.fastify.hasPlugin('@fastify/swagger'))
7673
}
7774

tests/unit/router/RouterTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export default class RouterTest {
129129
}
130130

131131
@Test()
132-
public async shouldBeAbleToRegistryARouteThatWillAutomaticallyRenderAView({ assert }: Context) {
132+
public async shouldBeAbleToRegisterARouteThatWillAutomaticallyRenderAView({ assert }: Context) {
133133
View.createComponent('test', '<h1>{{ name }}</h1>')
134134
Route.view('/test', 'test', { name: 'lenon' })
135135
Route.register()

0 commit comments

Comments
 (0)