Skip to content

Commit

Permalink
Merge pull request #62 from Michaelpalacce/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Michaelpalacce committed Jan 22, 2022
2 parents bdad0a2 + bfdeb8e commit 9832d54
Show file tree
Hide file tree
Showing 81 changed files with 1,038 additions and 1,208 deletions.
5 changes: 5 additions & 0 deletions UPDATELOG.md
@@ -1,3 +1,8 @@
34.0.0
* Housekeeping, more work done on JSDoc
* Improvements to file streams. Implemented MimeTypes in image file stream
* Changed the default makeId length to 32

33.5.0
* Housekeeping, work done on JSDoc

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -61,7 +61,7 @@
"test": "nyc --reporter=lcov --reporter=text-summary node --unhandled-rejections=strict test.js --debug",
"deploy": "npm run test && npm publish"
},
"version": "33.5.0",
"version": "34.0.0",
"devDependencies": {
"nyc": "^15.1.0"
}
Expand Down
43 changes: 21 additions & 22 deletions server/components/big_map/big_map.js
Expand Up @@ -8,15 +8,15 @@ class BigMap {
}

/**
* @brief Sets the value for the given key
* @brief Sets the value for the given key
*
* @details This function will create a new Map as is needed
* A new map will be created every 8,000,000 keys
* @details This function will create a new Map as is needed
* A new map will be created every 8,000,000 keys
*
* @property {*} key - the key to set
* @property {*} value - the value to set
* @param {*} key - the key to set
* @param {*} value - the value to set
*
* @return *
* @return *
*/
set( key, value ) {
let mapToSet = null;
Expand All @@ -37,11 +37,11 @@ class BigMap {
}

/**
* @brief Gets a value given a key
* @brief Gets a value given a key
*
* @property {*} key - the key to get
* @param {*} key - the key to get
*
* @return {*} - element that was set
* @return {*} - element that was set
*/
get( key ) {
const map = this._findMapWithKey( key );
Expand All @@ -53,13 +53,13 @@ class BigMap {
}

/**
* @brief Deletes a value given a key
* @brief Deletes a value given a key
*
* @details This will remove the Map if it becomes empty when the key is deleted
* @details This will remove the Map if it becomes empty when the key is deleted
*
* @property {*} key - the key of the value to delete
* @param {*} key - the key of the value to delete
*
* @return * - The value that was deleted
* @return * - The value that was deleted
*/
delete( key ) {
const map = this._findMapWithKey( key );
Expand All @@ -76,11 +76,11 @@ class BigMap {
}

/**
* @brief Checks if a key exists
* @brief Checks if a key exists
*
* @property {*} key - the key to check if exists
* @param {*} key - the key to check if exists
*
* @return {Boolean} - a flag whether the key exists
* @return {Boolean} - a flag whether the key exists
*/
has( key ) {
return typeof this._findMapWithKey( key ) !== 'undefined';
Expand Down Expand Up @@ -114,8 +114,8 @@ class BigMap {
}

/**
* @property {Function} callbackFn - function that will be called
* @property {*} thisArg - this argument to bind to
* @param {Function} callbackFn - function that will be called
* @param {*} thisArg - this argument to bind to
*/
forEach ( callbackFn, thisArg ) {
if ( thisArg )
Expand Down Expand Up @@ -193,13 +193,12 @@ class BigMap {
}

/**
* @brief Finds which map exactly has the given key and returns it
*
* @property {*} key
* @brief Finds which map exactly has the given key and returns it
*
* @private
* @param {*} key
*
* @return {Map}
* @return {Map}
*/
_findMapWithKey( key ) {
for ( let index = this.maps.length - 1; index >= 0; index-- ) {
Expand Down
18 changes: 9 additions & 9 deletions server/components/body_parsers/form_body_parser.js
Expand Up @@ -15,9 +15,9 @@ const CONTENT_TYPE_HEADER = 'content-type';
*/
class FormBodyParser extends EventEmitter {
/**
* @property {Object} options
* @property {Number} options.maxPayloadLength - The max size of the body to be parsed
* @property {Boolean} options.strict - Whether the received payload must match the content-length
* @param {Object} options
* @param {Number} options.maxPayloadLength - The max size of the body to be parsed
* @param {Boolean} options.strict - Whether the received payload must match the content-length
*/
constructor( options = {} ) {
super();
Expand All @@ -34,24 +34,24 @@ class FormBodyParser extends EventEmitter {
}

/**
* @brief Returns true if the current body parser supports teh given request
* @brief Returns true if the current body parser supports teh given request
*
* @property {EventRequest} event - The current EventRequest
* @param {EventRequest} event - The current EventRequest
*
* @return {Boolean} - Returns Boolean if the `content-type` is supported
* @return {Boolean} - Returns Boolean if the `content-type` is supported
*/
supports( event ) {
const contentType = event.getRequestHeader( CONTENT_TYPE_HEADER );
return typeof contentType === 'string' && contentType.match( FORM_PARSER_SUPPORTED_TYPE ) !== null;
}

/**
* @brief Parses the request
* @brief Parses the request
*
* @async
* @property {EventRequest} event
* @param {EventRequest} event
*
* @return {Promise<Object>}
* @return {Promise<Object>}
*/
parse( event ) {
return new Promise(( resolve, reject ) => {
Expand Down
18 changes: 9 additions & 9 deletions server/components/body_parsers/json_body_parser.js
Expand Up @@ -15,9 +15,9 @@ const CONTENT_TYPE_HEADER = 'content-type';
*/
class JsonBodyParser extends EventEmitter {
/**
* @property {Object} [options={}]
* @property {Number} options.maxPayloadLength - The max size of the body to be parsed
* @property {Boolean} options.strict - Whether the received payload must match the content-length
* @param {Object} [options={}]
* @param {Number} options.maxPayloadLength - The max size of the body to be parsed
* @param {Boolean} options.strict - Whether the received payload must match the content-length
*/
constructor( options = {} ) {
super();
Expand All @@ -34,24 +34,24 @@ class JsonBodyParser extends EventEmitter {
}

/**
* @brief Returns a boolean if the current body parser supports the request
* @brief Returns a boolean if the current body parser supports the request
*
* @property {EventRequest} event
* @param {EventRequest} event
*
* @return {Boolean}
* @return {Boolean}
*/
supports( event ) {
const contentType = event.getRequestHeader( CONTENT_TYPE_HEADER );
return typeof contentType === 'string' && contentType.match( JSON_BODY_PARSER_SUPPORTED_TYPE ) !== null;
}

/**
* @brief Parses the request
* @brief Parses the request
*
* @async
* @property {EventRequest} event
* @param {EventRequest} event
*
* @return {Promise<Object>}
* @return {Promise<Object>}
*/
parse( event ) {
return new Promise(( resolve, reject ) => {
Expand Down
70 changes: 35 additions & 35 deletions server/components/body_parsers/multipart_data_parser.js
Expand Up @@ -46,10 +46,10 @@ const ERROR_INVALID_METADATA = 'app.er.bodyParser.multipart.invalidMetadata'
*/
class MultipartDataParser extends EventEmitter {
/**
* @property {Object} [options={}]
* @property {Number} options.maxPayload - Maximum payload in bytes to parse if set to 0 means infinite
* @property {String} options.tempDir - The directory where to keep the uploaded files before moving
* @property {String} options.cleanUpItemsTimeoutMS - After what time should the files be deleted if any. Defaults to 100
* @param {Object} [options={}]
* @param {Number} options.maxPayload - Maximum payload in bytes to parse if set to 0 means infinite
* @param {String} options.tempDir - The directory where to keep the uploaded files before moving
* @param {String} options.cleanUpItemsTimeoutMS - After what time should the files be deleted if any. Defaults to 100
*/
constructor( options = {} ) {
super();
Expand Down Expand Up @@ -112,9 +112,9 @@ class MultipartDataParser extends EventEmitter {
}

/**
* @brief Upgrades the given data part and adds it DATA_TYPE_FILE properties
* @brief Upgrades the given data part and adds it DATA_TYPE_FILE properties
*
* @property {Object} part
* @param {Object} part
*/
upgradeToFileTypePart( part ) {
part.file = null;
Expand All @@ -123,9 +123,9 @@ class MultipartDataParser extends EventEmitter {
}

/**
* @brief Upgrades the given data part and adds it DATA_TYPE_PARAMETER properties
* @brief Upgrades the given data part and adds it DATA_TYPE_PARAMETER properties
*
* @property {Object} part
* @param {Object} part
*/
upgradeToParameterTypePart( part ) {
part.type = DATA_TYPE_PARAMETER;
Expand Down Expand Up @@ -172,9 +172,9 @@ class MultipartDataParser extends EventEmitter {
}

/**
* @brief Determines the OS line end and sets it for future use
* @brief Determines the OS line end and sets it for future use
*
* @property {Buffer} chunk
* @param {Buffer} chunk
*/
determineEOL( chunk ) {
const data = chunk.toString( DEFAULT_BUFFER_ENCODING );
Expand All @@ -189,9 +189,9 @@ class MultipartDataParser extends EventEmitter {
}

/**
* @brief Callback called when data is received by the server
* @brief Callback called when data is received by the server
*
* @property {Buffer} chunk
* @param {Buffer} chunk
*/
onDataReceivedCallback( chunk ) {
try {
Expand All @@ -203,10 +203,10 @@ class MultipartDataParser extends EventEmitter {
}

/**
* @brief Flushes the given buffer to the part.file stream
* @brief Flushes the given buffer to the part.file stream
*
* @property {Object} part
* @property {Buffer} buffer
* @param {Object} part
* @param {Buffer} buffer
*/
flushBuffer( part, buffer ) {
if ( part.type === DATA_TYPE_PARAMETER )
Expand All @@ -220,9 +220,9 @@ class MultipartDataParser extends EventEmitter {
}

/**
* @brief Extracts chunk data as they come in
* @brief Extracts chunk data as they come in
*
* @property {Buffer} chunk
* @param {Buffer} chunk
*/
extractChunkData( chunk ) {
let boundaryOffset = 0;
Expand Down Expand Up @@ -390,34 +390,34 @@ class MultipartDataParser extends EventEmitter {
}

/**
* @brief Emits an event with an error
* @brief Emits an event with an error
*
* @property {String} message - The message to throw
* @param {String} message - The message to throw
*/
handleError( message ) {
throw new Error( message );
}

/**
* @brief Return if the current body type is supported by the current body parser
* @brief Return if the current body type is supported by the current body parser
*
* @property {EventRequest} event
* @param {EventRequest} event
*
* @return {Boolean}
* @return {Boolean}
*/
supports( event ) {
const contentType = event.getRequestHeader( CONTENT_TYPE_HEADER );
return typeof contentType === 'string' && contentType.match( MULTIPART_PARSER_SUPPORTED_TYPE ) !== null;
}

/**
* @brief Get header data from event
* @brief Get header data from event
*
* @details Will return false on error
* @details Will return false on error
*
* @property {Object} headers - The headers object to extract the needed headers from
* @param {Object} headers - The headers object to extract the needed headers from
*
* @return {Object|Boolean}
* @return {Object|Boolean}
*/
static getHeaderData( headers ) {
const contentType = typeof headers[CONTENT_TYPE_HEADER] === 'string'
Expand All @@ -443,12 +443,12 @@ class MultipartDataParser extends EventEmitter {
}

/**
* @brief Parses the body
* @brief Parses the body
*
* @async
* @property {EventRequest} event
* @param {EventRequest} event
*
* @return {Promise}
* @return {Promise}
*/
parse( event ) {
return new Promise(( resolve, reject ) => {
Expand Down Expand Up @@ -488,11 +488,11 @@ class MultipartDataParser extends EventEmitter {
}

/**
* @brief Integrity check the event header data and payload length
* @brief Integrity check the event header data and payload length
*
* @brief Returns an error and header data in the callback
* @brief Returns an error and header data in the callback
*
* @property {Function} callback
* @param {Function} callback
*/
integrityCheck( callback ) {
let headerData = MultipartDataParser.getHeaderData( this.event.headers );
Expand Down Expand Up @@ -528,12 +528,12 @@ class MultipartDataParser extends EventEmitter {
}

/**
* @brief Extracted for testing purposes
* @brief Extracted for testing purposes
*
* @private
* @details I can't simulate an error when unlinking so this test is ignored for now
* @details I can't simulate an error when unlinking so this test is ignored for now
*
* @property {String} absFilePath - path of the file to remove
* @param {String} absFilePath - path of the file to remove
*/
_removeFile( absFilePath ) {
/* istanbul ignore next */
Expand Down

0 comments on commit 9832d54

Please sign in to comment.