const Messaging = require('./messaging').Messaging; const RequestParser = require(`./RequestParser`).RequestParser; class ParserAPI { /* Custom paths used for the API. */ #paths = { "parser": "/whoami" } /* Create the header parser API. @param {Express} INSTANCE - The Express instance */ constructor(INSTANCE) { this[`instance`] = INSTANCE; this.receive(); } /* Receive requests. */ receive() { [`get`, `post`].forEach((METHOD) => { this[`instance`][METHOD](`/api${this.#paths["parser"]}`, (REQUEST, RESPONSE) => { try { let PARSER = new RequestParser(REQUEST); RESPONSE.json(PARSER.getHeaders()); } catch(ERROR) {Messaging.exception(RESPONSE, ERROR)} }) }) } } module.exports = {ParserAPI}