Skip to content

Commit

Permalink
server: remove some unnecessary code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeorpinel committed Jan 5, 2020
1 parent 1a8bbda commit 6e0f9f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
9 changes: 3 additions & 6 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ app.prepare().then(() => {
const { pathname, query } = parsedUrl

/*
* Special URL redirects.
* HTTP redirects
* NOTE: The order of the redirects is important.
*/
if (
Expand Down Expand Up @@ -111,14 +111,12 @@ app.prepare().then(() => {
res.end()
} else if (/^\/doc(\/.*)?$/.test(pathname)) {
/*
* Special Docs Engine handler
* Based on /pages/doc.js page.
* Docs Engine handler
*/

// Force 404 response for any inexistent /doc item.
// Force 404 response code for any inexistent /doc item.
if (!getItemByPath(pathname)) {
res.statusCode = 404
// NOTE: Assumes the route below will render a 404 page.
}

// Custom route for all docs
Expand All @@ -128,7 +126,6 @@ app.prepare().then(() => {
handle(req, res, parsedUrl)
}
}).listen(port, err => {
// Invokes `createServer` server.
if (err) throw err
console.info(`> Ready on localhost:${port}`)
})
Expand Down
11 changes: 0 additions & 11 deletions src/utils/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/

const startCase = require('lodash.startcase')

// Base to build the target struct described above
const sidebar = require('../../public/static/docs/sidebar.json')

const PATH_ROOT = '/doc/'
Expand Down Expand Up @@ -58,7 +56,6 @@ function findItem(data, targetPath) {
}
}

// Recursive
function findPrevItemWithSource(data, item) {
if (item && item.source) {
return item
Expand Down Expand Up @@ -93,7 +90,6 @@ function normalizeItem({ rawItem, parentPath, resultRef, prevRef }) {
}
}

// Recursive
function normalizeSidebar({
data,
parentPath,
Expand Down Expand Up @@ -137,7 +133,6 @@ function normalizeSidebar({
return currentResult
}

// Recursive
function findChildWithSource(item) {
return item.source ? item : findChildWithSource(item.children[0])
}
Expand All @@ -146,17 +141,11 @@ function findChildWithSource(item) {
* Exports
*/

// Runs at module load time
const normalizedSidebar = normalizeSidebar({
data: sidebar,
parentPath: ''
})

/**
* Finds `path` in sidebar struct
* @param {*} path
* @uses `normalizedSidebar`
*/
function getItemByPath(path) {
const normalizedPath = path.replace(/\/$/, '')
const isRoot = normalizedPath === PATH_ROOT.slice(0, -1)
Expand Down

0 comments on commit 6e0f9f6

Please sign in to comment.