File tree Expand file tree Collapse file tree 3 files changed +9
-65
lines changed Expand file tree Collapse file tree 3 files changed +9
-65
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ const compression = require("compression")
66const helmet = require ( "helmet" )
77const config = require ( "./config.json" )
88const MongoClient = require ( "mongodb" )
9- const Path = require ( "path" )
109const app = express ( )
1110
1211const home = require ( "./routes/v1-home" )
@@ -30,9 +29,15 @@ app.use("/v1/launches", launches)
3029app . use ( "/v1/launches/upcoming" , upcoming )
3130app . use ( "/v1/parts" , parts )
3231
32+ // Global content type
33+ app . use ( ( req , res , next ) => {
34+ res . header ( "Content-Type" , "application/json" )
35+ next ( )
36+ } )
37+
3338// 404 Error Handler
3439app . use ( ( req , res ) => {
35- res . status ( 404 ) . sendFile ( Path . join ( __dirname + "/pages/404.html" ) )
40+ res . status ( 404 ) . json ( "No Endpoint Found" )
3641} )
3742
3843MongoClient . connect ( config . url , ( err , database ) => {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -12,9 +12,10 @@ beforeAll((done) => {
1212// 404 Page
1313//------------------------------------------------------------
1414
15- test ( "It should return 404 page " , ( ) => {
15+ test ( "It should return 404 endpoint error " , ( ) => {
1616 return request ( app ) . get ( "/v2" ) . then ( response => {
1717 expect ( response . statusCode ) . toBe ( 404 )
18+ expect ( response . text ) . toContain ( "No Endpoint Found" )
1819 } )
1920} )
2021
You can’t perform that action at this time.
0 commit comments