diff --git a/.gitignore b/.gitignore index cc1973b..85d668f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .vscode node_modules .nyc_output +coverage \ No newline at end of file diff --git a/coverage/app.js.html b/coverage/app.js.html deleted file mode 100644 index 7e7743d..0000000 --- a/coverage/app.js.html +++ /dev/null @@ -1,321 +0,0 @@ - - -
-- Press n or j to go to the next uncovered block, b, p or k for the previous block. -
-1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 -79 -80 -81 -82 -83 -84 -85 | - -1x -1x -1x -1x - -1x - -1x -1x - - - - - - -1x -1x -1x -1x - - - - -1x -5x -3x -3x -2x - -1x - - - - -1x - - - - -3x -3x -3x - -1x - -2x - - -1x -1x - - -1x -1x - - -1x -1x - - - - - -1x -1x - - -1x -2x - -2x -2x -1x - -1x - -1x - - -1x -1x - -1x | 'use strict' - -const express = require('express') -const fs = require('fs') -const path = require('path') -const app = express() - -app.set('view engine', 'ejs') - -app.get('/', (req, res) => { - res.render('pages/index', { - title: "Levi Olson", - active: "home", - content: "" - }) -}) - -app.get('/posts', (req, res) => { - const postDir = __dirname + '/posts' - let files = fs.readdirSync(postDir, 'utf8') - let data = { - title: "Posts - Levi Olson", - active: "posts", - posts: [] - } - for (let i = 0; i < files.length; i++) { - if (path.extname(files[i]) === '.json') { - let postData = getData(files[i]) - if (postData) { - data.posts.push(postData) - } else { - console.log(files[i], 'does not have a corresponding "html" file') - } - } - } - - res.render('pages/posts', data) -}) - -function getData(file) { - let postData - try { - postData = JSON.parse(fs.readFileSync('./posts/' + file, 'utf8')) - postData.content = fs.readFileSync('./posts/' + postData.content_file, 'utf8') - } catch (e) { - return - } - return postData -} - -app.get('/about', (req, res) => { - res.sendFile(__dirname + '/views/pages/about.html') -}) - -app.get('/uncopyright', (req, res) => { - return res.sendFile(__dirname + '/views/pages/uncopyright.html') -}) - -app.get('/404', (req, res) => { - return res.status(404).render('pages/404', { - title: "Page Not Found - Levi Olson", - active: "" - }) -}) - -app.get('/core.css', (req, res) => { - res.sendFile(__dirname + '/core.css') -}) - -app.get('/posts/:post', (req, res) => { - let post = req.params.post - let postData - try { - postData = JSON.parse(fs.readFileSync('./posts/' + post + '.json', 'utf8')) - postData.content = fs.readFileSync('./posts/' + postData.content_file, 'utf8') - } catch (e) { - return res.redirect('/404') - } - return res.render('pages/post', postData) -}) - -const port = 5000 -app.listen(port, () => console.log('Example app listening on port ' + port + '!')) - -module.exports = app |
- Press n or j to go to the next uncovered block, b, p or k for the previous block. -
-File | -- | Statements | -- | Branches | -- | Functions | -- | Lines | -- |
---|---|---|---|---|---|---|---|---|---|
app.js | -100% | -42/42 | -100% | -4/4 | -100% | -9/9 | -100% | -41/41 | -