Skip to content

Commit

Permalink
Updating app files
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsislimadev committed Jan 2, 2025
1 parent dd4d215 commit caa3d6d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import { HttpResponse } from './response.js'
import { Router } from './router.js'

export class Server {

port = 80

router = new Router()

intances = {}

addRequest(method = 'GET', path = '/', fn = (() => { })) {
this.router.request(method, path, fn)
return this
Expand Down Expand Up @@ -34,7 +38,7 @@ export class Server {
listen(port = this.port) {
const self = this

return new Promise((res) => {
return this.intances[port] = new Promise((res) => {
const server = netPkg.createServer((socket) => {
socket.on('data', (buffer) => {
const req = new HttpRequest(buffer.toString())
Expand Down

0 comments on commit caa3d6d

Please sign in to comment.