-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from FACN3/modularization
Modularize the handler.js file and clean up with Linter
- Loading branch information
Showing
10 changed files
with
205 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// handles the Errors | ||
const handleError = (error, request, response) => { | ||
response.writeHead(404, { 'Content-Type': 'text/html' }); | ||
response.end('<h1>404 PAGE NOT FOUND </h1>'); | ||
}; | ||
|
||
module.exports = handleError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const handleError = require('./handleError'); | ||
|
||
const handleHome = (request, response) => { | ||
const filePath = path.join(__dirname, '..', '..', 'public', 'index.html'); | ||
fs.readFile(filePath, (error, file) => { | ||
if (error) { | ||
handleError(error, request, response); | ||
} else { | ||
response.writeHead(200, { 'Context-Type': 'text/html' }); | ||
response.end(file); | ||
} | ||
}); | ||
}; | ||
|
||
module.exports = handleHome; |
Oops, something went wrong.