Skip to content

Commit f6cc6ab

Browse files
committed
fix(fileop) authCheck -> auth
1 parent d8b97fd commit f6cc6ab

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ app.use(fileop({
9898
fileop.listen(socket, {
9999
prefix: '/fileop', /* default */
100100
root: '/', /* string or function */
101-
authCheck: (accept, reject) => (username, password) => {
101+
auth: (accept, reject) => (username, password) => {
102102
if (username === 'root' && password === 'toor')
103103
accept();
104104

server/listen.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@ const inc = (a) => a(a() + 1);
1717

1818
module.exports = listen;
1919

20-
function check(authCheck) {
21-
if (authCheck && typeof authCheck !== 'function')
22-
throw Error('authCheck should be function!');
20+
function check(auth) {
21+
if (auth && typeof auth !== 'function')
22+
throw Error('auth should be function!');
2323
}
2424

2525
function listen(socket, options) {
2626
options = options || {};
2727

28-
const authCheck = options.authCheck;
28+
const auth = options.auth;
2929
const prefix = options.prefix || '/fileop';
3030
const root = options.root || '/';
3131

32-
check(authCheck);
32+
check(auth);
3333

3434
socket.of(prefix)
3535
.on('connection', (socket) => {
36-
if (!authCheck)
36+
if (!auth)
3737
return connection(root, socket);
3838

3939
const reject = () => socket.emit('reject');
40-
socket.on('auth', authCheck(connectionWraped(root, socket), reject));
40+
socket.on('auth', auth(connectionWraped(root, socket), reject));
4141
});
4242
}
4343

test/client/fileop.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ test('client: disconnect', async (t) => {
229229
});
230230

231231
test('client: auth: reject', async (t) => {
232-
const authCheck = (accept, reject) => () => {
232+
const auth = (accept, reject) => () => {
233233
reject();
234234
};
235235

236-
const {done, origin} = await connect({authCheck});
236+
const {done, origin} = await connect({auth});
237237

238238
before({origin});
239239

@@ -252,14 +252,14 @@ test('client: auth: reject', async (t) => {
252252
});
253253

254254
test('client: options', async (t) => {
255-
const authCheck = (accept) => () => {
255+
const auth = (accept) => () => {
256256
accept();
257257
};
258258

259259
const prefix = '/hello';
260260
const {done, origin} = await connect({
261261
prefix,
262-
authCheck,
262+
auth,
263263
});
264264

265265
before({origin});

test/server/fileop.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ test('fileop: options: empty object', async (t) => {
2525
t.end();
2626
});
2727

28-
test('fileop: options: authCheck not function', async (t) => {
29-
const authCheck = {};
30-
const [error] = await tryToCatch(connect, {authCheck});
28+
test('fileop: options: auth not function', async (t) => {
29+
const auth = {};
30+
const [error] = await tryToCatch(connect, {auth});
3131

32-
t.equal(error.message, 'authCheck should be function!', 'should throw when authCheck not function');
32+
t.equal(error.message, 'auth should be function!', 'should throw when auth not function');
3333
t.end();
3434
});
3535

36-
test('fileop: options: authCheck: reject', async (t) => {
37-
const authCheck = (accept, reject) => () => {
36+
test('fileop: options: auth: reject', async (t) => {
37+
const auth = (accept, reject) => () => {
3838
reject();
3939
};
4040

41-
const {socket, done} = await connect({authCheck});
41+
const {socket, done} = await connect({auth});
4242

4343
socket.emit('auth');
4444
socket.on('reject', () => {
@@ -49,12 +49,12 @@ test('fileop: options: authCheck: reject', async (t) => {
4949
});
5050
});
5151

52-
test('fileop: options: authCheck: accept', async (t) => {
53-
const authCheck = (accept) => () => {
52+
test('fileop: options: auth: accept', async (t) => {
53+
const auth = (accept) => () => {
5454
accept();
5555
};
5656

57-
const {socket, done} = await connect({authCheck});
57+
const {socket, done} = await connect({auth});
5858

5959
socket.emit('auth', 'hello', 'world');
6060

@@ -66,19 +66,19 @@ test('fileop: options: authCheck: accept', async (t) => {
6666
});
6767
});
6868

69-
test('fileop: options: authCheck: accept', async (t) => {
69+
test('fileop: options: auth: accept', async (t) => {
7070
const user = 'bill';
7171
const pass = 'world';
7272

73-
const authCheck = currify((accept, reject, username, password) => {
73+
const auth = currify((accept, reject, username, password) => {
7474
done();
7575

7676
t.equal(username, user, 'should pass username');
7777
t.equal(password, pass, 'should pass password');
7878
t.end();
7979
});
8080

81-
const {socket, done} = await connect({authCheck});
81+
const {socket, done} = await connect({auth});
8282

8383
socket.emit('auth', user, pass);
8484
});

0 commit comments

Comments
 (0)