Skip to content

Commit 6c429ad

Browse files
committed
tabs -> spaces
1 parent 8be2940 commit 6c429ad

2 files changed

Lines changed: 25 additions & 18 deletions

File tree

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = false
6+
indent_style = space
7+
indent_size = 2

index.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ const { send, createError } = require('micro')
66
const db = then(level('blog-views'))
77

88
module.exports = async function (req, res) {
9-
// Check that a blogpost is provided
10-
const { pathname } = url.parse(req.url)
11-
if (pathname.length <= 1) {
12-
throw createError(400, 'Please include a path to a blogpost.')
13-
}
14-
// Get the views
15-
let views
16-
try {
17-
views = parseInt(await db.get(pathname), 10)
18-
} catch (err) {
19-
// If the post doesn't have views yet, initialise the post with one view
20-
await db.put(pathname, 1)
21-
send(res, 200, { views: 1 })
22-
return
23-
}
24-
// Increment the views and send them back to client
25-
await db.put(pathname, views + 1)
26-
send(res, 200, { views: views + 1 })
9+
// Check that a blogpost is provided
10+
const { pathname } = url.parse(req.url)
11+
if (pathname.length <= 1) {
12+
throw createError(400, 'Please include a path to a blogpost.')
13+
}
14+
// Get the views
15+
let views
16+
try {
17+
views = parseInt(await db.get(pathname), 10)
18+
} catch (err) {
19+
// If the post doesn't have views yet, initialise the post with one view
20+
await db.put(pathname, 1)
21+
send(res, 200, { views: 1 })
22+
return
23+
}
24+
// Increment the views and send them back to client
25+
await db.put(pathname, views + 1)
26+
send(res, 200, { views: views + 1 })
2727
}

0 commit comments

Comments
 (0)