Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions server/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const fs = require('fs')
const { lookupMimeType } = require('../lib/utils')
const path = require('path')


const STATUS_CODES = Object.freeze({
200: 'OK',
201: 'Created',
Expand All @@ -25,16 +24,15 @@ const STATUS_CODES = Object.freeze({
503: 'Service Unavailable'
})


/**
* Response class for handling HTTP responses.
*
*
* @class Response
*
*
* @param {Socket} socket - The socket object for the response.
* @param {boolean} enableCors - Enable Cross-Origin Resource Sharing (CORS).
* @param {string} statusTextMap - Map of status codes to status texts.
* @example
* @example
* ```javascript
const Response = require('./response.js');

Expand Down Expand Up @@ -68,7 +66,7 @@ class Response {
}

/**
*
*
* @param {number} code - The HTTP status code.
* @returns - The Response instance.
*/
Expand All @@ -81,7 +79,7 @@ class Response {
}

/**
*
*
* @param {string} key - The header key.
* @param {string} value - The header value.
* @returns - The Response instance.
Expand Down Expand Up @@ -113,7 +111,7 @@ class Response {
}

/**
*
*
* @param {string} data - The data to send.
* @returns - If the data is an object or array, send as JSON
*/
Expand Down Expand Up @@ -142,7 +140,7 @@ class Response {
}

/**
*
*
* @param {number} statusCode - The HTTP status code.
* Updates the status code and sends the status code as a response.
*/
Expand All @@ -154,7 +152,7 @@ class Response {
}

/**
*
*
* @param {*} data - The data to send.
*/
json (data) {
Expand All @@ -170,7 +168,7 @@ class Response {
}

/**
*
*
* @param {*} file - The file to send.
*/
sendFile (file) {
Expand Down Expand Up @@ -205,7 +203,7 @@ class Response {
}

/**
*
*
* @param {*} file - The file to send.
* @param {*} filename - The filename to send.
*/
Expand Down
Loading