Skip to content

Commit 567d13d

Browse files
committed
Prettier added.
1 parent d6f2d25 commit 567d13d

File tree

9 files changed

+203
-135
lines changed

9 files changed

+203
-135
lines changed

.eslintrc.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"extends": [
3+
"prettier",
34
"eslint:recommended",
45
"plugin:node/recommended"
56
],
@@ -10,8 +11,12 @@
1011
"env": {
1112
"node": true,
1213
"mocha": true
13-
},
14+
},
15+
"plugins": [
16+
"prettier"
17+
],
1418
"rules": {
19+
"prettier/prettier": "error",
1520
"node/exports-style": ["error", "module.exports"],
1621
"node/file-extension-in-import": ["error", "always"],
1722
"node/prefer-global/buffer": ["error", "always"],

.npmignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.gitignore
22
node_modules
33
.project
4-
http-auth-koa.iml
4+
*.iml
55
.idea
66
.settings
77
_site
@@ -10,4 +10,5 @@ examples
1010
.travis.yml
1111
data
1212
.github
13-
.eslintrc.json
13+
.eslintrc.json
14+
.prettier.config.js

.prettier.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
tabWidth: 2,
3+
semi: true,
4+
singleQuote: true,
5+
trailingComma: 'es5',
6+
}

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@ $ npm install http-auth-koa
1919
## Usage
2020
```javascript
2121
// Authentication module.
22-
const auth = require('http-auth');
23-
const koaAuth = require('http-auth-koa');
22+
const auth = require("http-auth");
23+
const koaAuth = require("http-auth-koa");
2424

2525
const basic = auth.basic({
26-
realm: "Simon Area.",
27-
file: __dirname + "/../data/users.htpasswd"
26+
realm: "Simon Area.",
27+
file: __dirname + "/../data/users.htpasswd"
2828
});
2929

3030
// Koa setup.
31-
const Koa = require('koa');
31+
const Koa = require("koa");
3232
const app = new Koa();
3333

3434
// Setup basic handler.
3535
app.use(async (ctx, next) => {
36-
await next();
37-
ctx.body = `Welcome to koa ${ctx.req.user}!`;
36+
await next();
37+
ctx.body = `Welcome to koa ${ctx.req.user}!`;
3838
});
3939

4040
// Setup auth.
4141
app.use(koaAuth(basic));
4242

4343
// Start server.
44-
app.listen(1337, function () {
45-
// Log URL.
46-
console.log("Server running at http://127.0.0.1:1337/");
44+
app.listen(1337, function() {
45+
// Log URL.
46+
console.log("Server running at http://127.0.0.1:1337/");
4747
});
4848
```
4949

examples/app.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
// Authentication module.
2-
const auth = require('http-auth');
3-
const koaAuth = require('../src/index');
2+
const auth = require("http-auth");
3+
const koaAuth = require("../src/index");
44

55
const basic = auth.basic({
6-
realm: "Simon Area.",
7-
file: __dirname + "/../data/users.htpasswd"
6+
realm: "Simon Area.",
7+
file: __dirname + "/../data/users.htpasswd"
88
});
99

1010
// Koa setup.
11-
const Koa = require('koa');
11+
const Koa = require("koa");
1212
const app = new Koa();
1313

1414
// Setup basic handler.
1515
app.use(async (ctx, next) => {
16-
await next();
17-
ctx.body = `Welcome to koa ${ctx.req.user}!`;
16+
await next();
17+
ctx.body = `Welcome to koa ${ctx.req.user}!`;
1818
});
1919

2020
// Setup auth.
2121
app.use(koaAuth(basic));
2222

2323
// Start server.
24-
app.listen(1337, function () {
25-
// Log URL.
26-
console.log("Server running at http://127.0.0.1:1337/");
27-
});
24+
app.listen(1337, function() {
25+
// Log URL.
26+
console.log("Server running at http://127.0.0.1:1337/");
27+
});

package-lock.json

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
"url": "http://github.com/http-auth/http-auth-koa/issues"
2727
},
2828
"devDependencies": {
29+
"eslint-config-prettier": "^6.10.0",
30+
"eslint-plugin-prettier": "^3.1.2",
31+
"prettier": "^1.19.1",
2932
"chai": "^4.2.0",
3033
"eslint": "^6.8.0",
3134
"eslint-plugin-node": "^11.0.0",

src/index.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Export middleware.
2-
module.exports = (auth) => {
3-
return async (ctx, next) => {
4-
await auth.check((req, res, err) => {
5-
if (err) {
6-
throw err;
7-
} else {
8-
next();
9-
}
10-
})(ctx.req, ctx.res);
11-
};
12-
}
2+
module.exports = auth => {
3+
return async (ctx, next) => {
4+
await auth.check((req, res, err) => {
5+
if (err) {
6+
throw err;
7+
} else {
8+
next();
9+
}
10+
})(ctx.req, ctx.res);
11+
};
12+
};

0 commit comments

Comments
 (0)