Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchoz49 committed Jul 13, 2024
1 parent 8ec7219 commit bf05de8
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 53 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.44.0"
},
"devDependencies": {
"@fastify/static": "^7.0.3",
"@fastify/static": "^7.0.4",
"@types/events": "^3.0.2",
"@types/node": "^20.8.10",
"@types/streamx": "^2.9.3",
Expand All @@ -77,7 +77,7 @@
"simple-get": "^4.0.1",
"tap": "^16.3.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"typescript": "^5.5.3",
"uvu": "^0.5.3",
"ws": "^8.9.0"
},
Expand Down
1 change: 0 additions & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ export class Server extends EventEmitter {
if (this[kAddress].address.startsWith('[')) {
throw new ERR_ENOTFOUND(this[kAddress].address)
}

if (mainServer[port] && host !== 'localhost' && mainServer[port][kListenAll]) return

const parsedAddress = ipaddr.parse(this[kAddress].address)
Expand Down
12 changes: 12 additions & 0 deletions tests/check-listen.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import fastify from 'fastify'
import { test } from 'uvu'

import { serverFactory } from '../src/server.js'

test('fastify should listen succesful', async () => {
const app = fastify({ serverFactory })
await app.listen({ port: 3000 })
await app.close()
})

test.run()
3 changes: 2 additions & 1 deletion tests/http-socket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ test('writable drain', async () => {
res.end()
})

await new Promise(resolve => server.listen({ host: 'localhost' }, resolve))
server.listen({ host: 'localhost' })
await new Promise(resolve => server.once('listening', resolve))

const res = await fetch(`http://localhost:${server.address().port}`).then(
res => res.arrayBuffer()
Expand Down
97 changes: 49 additions & 48 deletions tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,54 @@ import testFastify from './fastify/index.cjs'
test('fastify integration tests', async () => {
const results = await testFastify(serverFactory, {
tests: [
// '404s',
// '500s',
// 'allowUnsafeRegex',
// 'als',
// 'async-await',
// 'bodyLimit',
// 'case-insensitive',
// 'close',
'404s',
'500s',
'allowUnsafeRegex',
'als',
'async-await',
'bodyLimit',
'case-insensitive',
'close',
'custom-parser-async',
// 'custom-querystring-parser',
// 'decorator',
// 'delete',
// 'genReqId',
// 'get',
// 'head',
// 'hooks-async',
// 'hooks',
// 'listen.1',
// 'listen.2',
// 'listen.3',
// 'listen.4',
// 'listen.5',
// 'nullable-validation',
// 'output-validation',
// 'promises',
// 'proto-poisoning',
// 'register',
// 'route-hooks',
// 'route.1',
// 'route.2',
// 'route.3',
// 'route.4',
// 'route.5',
// 'route.6',
// 'route.7',
// 'versioned-routes',
// 'schema-feature',
// 'server',
// 'internals/handleRequest',
// 'internals/reply',
// 'stream.1',
// 'stream.2',
// 'stream.3',
// 'stream.4',
// 'stream.5',
// 'https/https',
// 'url-rewriting',
// 'trust-proxy',
'custom-querystring-parser',
'decorator',
'delete',
'genReqId',
'get',
'head',
'hooks-async',
'hooks',
'listen.1',
'listen.2',
'listen.3',
'listen.4',
'listen.5',
'nullable-validation',
'output-validation',
'promises',
'proto-poisoning',
'register',
'route-hooks',
'route.1',
'route.2',
'route.3',
'route.4',
'route.5',
'route.6',
'route.7',
'versioned-routes',
'schema-feature',
'server',
'internals/handleRequest',
'internals/reply',
'stream.1',
'stream.2',
'stream.3',
'stream.4',
'stream.5',
'https/https',
'url-rewriting',
'trust-proxy',
],
ignore: [
'framework-unsupported method',
Expand All @@ -73,7 +73,8 @@ test('fastify integration tests', async () => {
'invalid response headers when sending back an error',
'invalid response headers and custom error handler',
'for HEAD method, no body should be sent but content-length should be',
'undefined payload should be sent as-is'
'undefined payload should be sent as-is',
'addresses getter',
],
})
console.log(results)
Expand Down
2 changes: 1 addition & 1 deletion types/fastify-overload.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IncomingMessage, ServerResponse, Server } from 'http';
import { FastifyRequest, RawServerBase, RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression, RequestGenericInterface, ContextConfigDefault, FastifyInstance, FastifySchema, FastifyTypeProvider, FastifyTypeProviderDefault, FastifyBaseLogger } from 'fastify';
import * as fastify from 'fastify';
import { RouteGenericInterface } from 'fastify/types/route.js';
import type { WebSocketServer, WebSocket } from './websocket-server.js';
import type { WebSocketServer, WebSocket } from '../src/websocket-server.js';

declare module 'fastify' {
interface RouteShorthandOptions<
Expand Down

0 comments on commit bf05de8

Please sign in to comment.