Skip to content

Commit 04f2e98

Browse files
committed
Added the error handling and docs support
1 parent 7ae1504 commit 04f2e98

25 files changed

+3684
-84
lines changed

api/app.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
const express = require('express')
22
const cors = require('cors')
33
const rateLimit = require('express-rate-limit')
4+
const {
5+
badRequestHandler,
6+
requestMethodHandler,
7+
internalServerErrorHandler,
8+
} = require('../src/errorHandler')
49

510
const app = express()
611

@@ -33,7 +38,17 @@ app.use(express.json())
3338
// express middleware handling the form parsing
3439
app.use(express.urlencoded({extended: false}))
3540

41+
// middleware to handle wrong method types
42+
app.use(requestMethodHandler)
43+
3644
// middleware for handling sample api routes
3745
app.use('/api/v1', require('../routes/api/v1/API'))
46+
app.use(express.static('docs'))
47+
48+
// middleware to handle internal server errors due to implementation
49+
app.use(internalServerErrorHandler)
50+
51+
// middleware to handle bad requests
52+
app.use(badRequestHandler)
3853

3954
module.exports = app

apidoc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "Code Rating Engine",
3+
"version": "1.0.0",
4+
"description": "Engine to handle the rating mechanisms for the clean code",
5+
"title": "Code Rating Engine",
6+
"url": "https://coderatingengine-techous.vercel.app"
7+
}
7.49 KB
Loading
28.3 KB
Loading

docs/assets/apple-touch-icon.png

8.57 KB
Loading

docs/assets/bootstrap.min.css

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/bootstrap.min.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/favicon-16x16.png

566 Bytes
Loading

docs/assets/favicon-32x32.png

1.13 KB
Loading

docs/assets/favicon.ico

24.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)