rjweb-server
Version:
Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS
35 lines (34 loc) • 669 B
JavaScript
class RouteContentTypes {
/** Generate Content Type Block */
constructor(contentTypes = {}) {
this.contentTypes = contentTypes;
}
/**
* Add A File -> Content Type Mapping
* @example
* ```
* const controller = new Server({ })
*
* controller.contentTypes((cT) => cT
* .add('.png', 'image/png')
* )
* ```
* @since 5.3.0
*/
add(ending, contentType) {
this.contentTypes[ending] = contentType;
return this;
}
/**
* Internal Method for Generating Content Types Object
* @since 5.3.0
*/
getData() {
return {
contentTypes: this.contentTypes
};
}
}
export {
RouteContentTypes as default
};