Skip to content

Commit

Permalink
Adding documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gprendi committed Mar 8, 2022
1 parent b9f39e4 commit bcb8522
Show file tree
Hide file tree
Showing 10 changed files with 373 additions and 116 deletions.
18 changes: 17 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@
"ecmaVersion": "latest"
},
"rules": {
"semi": [2, "always"]
"semi": [2, "always"],
"arrow-spacing": "off",
"no-multi-spaces": "off",
"no-multiple-empty-lines": "off",
"indent": ["warn", 4],
"no-unused-vars": "warn",
"no-trailing-spaces": "warn",
"padded-blocks": "warn",
"quotes": "warn",
"spaced-comment": "warn",
"node/no-path-concat": "off",
"eol-last": "warn",
"no-new-wrappers": "off",
"no-useless-escape": "off",
"no-undef": "warn",
"space-before-function-paren": "warn",
"quote-props": "warn"
},
"ignorePatterns": ["src/test/*"]
}
134 changes: 123 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"chai": "4.3.6",
"dotenv": "16.0.0",
"express": "4.17.3",
"http-errors": "2.0.0",
"mocha": "9.2.1",
"supertest": "6.2.2"
}
Expand Down
27 changes: 18 additions & 9 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
/**
* Driver code for http server
* @namespace App
*/

const express = require('express');
const routers = require('./routes');
const createError = require('http-errors');

const routers = require('./routes');

/**
* @typedef {Object} App;
* @description Express Object
* @memberof App
*/
const app = express();

app.use(express.json({ limit: '4MB' }));
Expand All @@ -11,18 +22,16 @@ app.use('/romannumeral', routers.romanNumeral);

// catch 404 and forward to error handler
app.use(function (req, res, next) {
res.status(404).send(
createError(404, 'Not Found')
);
res.status(404).send(createError(404));
});

app.use(function (req, res, next) {
// set locals, only providing error in development
// res.locals.message = err.message
// res.locals.error = req.app.get('env') === 'development' ? err : {}
// set locals, only providing error in development
// res.locals.message = err.message
// res.locals.error = req.app.get('env') === 'development' ? err : {}

// render the error page
res.status(500).end();
// render the error page
res.status(500).end();
});

module.exports = app;
52 changes: 39 additions & 13 deletions src/conversion/conversionErrors.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,49 @@

/**
* OutOfRangeError extends Error
* is thrown when the input is out of range
* @memberof DecimalToRomanConversion
*/
class OutOfRangeError extends Error {
constructor (message) {
super(message);
this.name = 'OutOfRangeError';
}
/**
* Initializes a new OutOfRangeError, using the supplied message;
* @param {string} message is the supplied message to the error.
*/
constructor (message) {
super(message);
this.name = 'OutOfRangeError';
}
}

/**
* InvalidInputError
* is thrown when the input is not valid.
* @memberof DecimalToRomanConversion
*/
class InvalidInputError extends Error {
constructor (message) {
super(message);
this.name = 'InvalidInputError';
}
/**
* Initializes a new InvalidError, using the supplied message;
* @param {string} message is the supplied message to the error.
*/
constructor (message) {
super(message);
this.name = 'InvalidInputError';
}
}

/**
* MissingParameterError
* is thrown when the input is not provided.
* @memberof DecimalToRomanConversion
*/
class MissingParameterError extends Error {
constructor (message) {
super(message);
this.name = 'MissingParameterError';
}
/**
* Initializes a new MissingParameterError, using the supplied message;
* @param {string} message is the supplied message to the error.
*/
constructor (message) {
super(message);
this.name = 'MissingParameterError';
}
}

module.exports = { OutOfRangeError, InvalidInputError, MissingParameterError };
Loading

0 comments on commit bcb8522

Please sign in to comment.