Skip to content

Commit 2182c74

Browse files
committed
fix lint in routes
1 parent 32df40f commit 2182c74

9 files changed

Lines changed: 31 additions & 35 deletions

File tree

routes/authentication.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const debug = require('debug')('authentication');
2-
const param = require('@cesine/swagger-node-express/Common/node/paramTypes.js');
2+
const param = require('@cesine/swagger-node-express/Common/node/paramTypes');
33
const sequelize = require('sequelize');
44
const querystring = require('querystring');
55

@@ -45,9 +45,6 @@ exports.postLogin = {
4545
password: req.body.password,
4646
username: req.body.username,
4747
}, (err, user) => {
48-
let token;
49-
let redirect;
50-
5148
delete req.body.password;
5249
if (err) {
5350
debug('error logging in', err, user);
@@ -57,12 +54,12 @@ exports.postLogin = {
5754
return next(err, req, res, next);
5855
}
5956

60-
token = signUserAsToken({ user });
57+
const token = signUserAsToken({ user });
6158
debug('token', token);
6259
res.set('Set-Cookie', `Authorization=Bearer ${token}; path=/; Secure; HttpOnly`);
6360
res.set('Authorization', `Bearer ${token}`);
6461

65-
redirect = req.body.redirect || `${req.body.redirect_uri}?${querystring.stringify(req.body)}`;
62+
const redirect = req.body.redirect || `${req.body.redirect_uri}?${querystring.stringify(req.body)}`;
6663
return res.redirect(redirect);
6764
});
6865
},
@@ -147,8 +144,6 @@ exports.postRegister = {
147144
}
148145

149146
return User.create(req.body, (createErr, user) => {
150-
let token;
151-
152147
if (createErr) {
153148
err = createErr;
154149
debug('Error registering the user', err, user);
@@ -164,7 +159,7 @@ exports.postRegister = {
164159
return next(err, req, res, next);
165160
}
166161

167-
token = signUserAsToken({ user });
162+
const token = signUserAsToken({ user });
168163
debug('token', token);
169164
res.set('Set-Cookie', `Authorization=Bearer ${token}; path=/; Secure; HttpOnly`);
170165
res.set('Authorization', `Bearer ${token}`);

routes/corpora.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const swagger = require('@cesine/swagger-node-express');
2-
const param = require('@cesine/swagger-node-express/Common/node/paramTypes.js');
3-
const corpusData = require('../lib/corpus.js');
2+
const param = require('@cesine/swagger-node-express/Common/node/paramTypes');
3+
const corpusData = require('../lib/corpus');
44

55
exports.getCorpora = {
66
spec: {
@@ -84,7 +84,7 @@ exports.deleteCorpora = {
8484
// If the user has admin permissions
8585
// Flag the corpus as deleted
8686
// Remove the corpus from the user's list of corpora and add it to the deleted list
87-
const id = parseInt(req.params.id);
87+
const id = parseInt(req.params.id, 10);
8888
corpusData.deleteCorpus(id);
8989
res.status(204);
9090
},

routes/data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Load modules provided by $ npm install, see package.json for details */
22
const swagger = require('@cesine/swagger-node-express');
3-
const param = require('../node_modules/@cesine/swagger-node-express/Common/node/paramTypes.js');
3+
const param = require('../node_modules/@cesine/swagger-node-express/Common/node/paramTypes');
44

55
exports.getData = {
66
spec: {

routes/elanguages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Load modules provided by $ npm install, see package.json for details */
22
const swagger = require('@cesine/swagger-node-express');
3-
const param = require('../node_modules/@cesine/swagger-node-express/Common/node/paramTypes.js');
3+
const param = require('../node_modules/@cesine/swagger-node-express/Common/node/paramTypes');
44

55
exports.getELanguages = {
66
spec: {

routes/files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Load modules provided by $ npm install, see package.json for details */
22
const swagger = require('@cesine/swagger-node-express');
3-
const param = require('../node_modules/@cesine/swagger-node-express/Common/node/paramTypes.js');
3+
const param = require('../node_modules/@cesine/swagger-node-express/Common/node/paramTypes');
44

55
exports.getFiles = {
66
spec: {

routes/morphologicalparses.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Load modules provided by $ npm install, see package.json for details */
22
const swagger = require('@cesine/swagger-node-express');
3-
const param = require('../node_modules/@cesine/swagger-node-express/Common/node/paramTypes.js');
3+
const param = require('../node_modules/@cesine/swagger-node-express/Common/node/paramTypes');
44

55
exports.getMorphologicalParses = {
66
spec: {

routes/oauth2.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const debug = require('debug')('oauth:routes');
2-
const param = require('@cesine/swagger-node-express/Common/node/paramTypes.js');
2+
const param = require('@cesine/swagger-node-express/Common/node/paramTypes');
33
const querystring = require('querystring');
44

5-
const errorMiddleware = require('../middleware/error-handler').errorHandler;
65
const oauth = require('../middleware/oauth');
76

87
/**
@@ -27,7 +26,6 @@ exports.getAuthorize = {
2726
nickname: 'getAuthorize',
2827
},
2928
action: function getAuthorize(req, res, next) {
30-
let middleware;
3129
debug('getAuthorize res.locals', res.locals);
3230
debug('req.path', req.path);
3331
debug('req.query', req.query);
@@ -42,11 +40,13 @@ exports.getAuthorize = {
4240
// https://oauth2-server.readthedocs.io/en/latest/api/oauth2-server.html#authorize-request-response-options-callback
4341
const authenticateHandler = {
4442
handle(request, response) {
43+
debug('request', request);
44+
debug('response', response);
4545
return res.locals.user;
4646
},
4747
};
4848

49-
middleware = oauth.authorize({
49+
const middleware = oauth.authorize({
5050
scope: req.query.scope,
5151
authenticateHandler,
5252
continueMiddleware: true, // does not call through
@@ -61,6 +61,7 @@ exports.getAuthorize = {
6161
return next(err);
6262
}
6363
// next(); // cannot set headers after they are set
64+
return null;
6465
});
6566
},
6667
};
@@ -86,11 +87,10 @@ exports.postToken = {
8687
nickname: 'postToken',
8788
},
8889
action: function postToken(req, res, next) {
89-
let middleware;
9090
debug('postToken', req.query, req.body, res.headers);
9191
// req.user = res.locals.user; TODO where does the user that is passed to client come from
9292

93-
middleware = oauth.token({
93+
const middleware = oauth.token({
9494
// continueMiddleware: true,
9595
});
9696

@@ -103,8 +103,8 @@ exports.postToken = {
103103
}
104104
// TODO this has no effect
105105
// instead working around it by return jwt in saveToken response as accesToken
106-
res.set('Authorization', `Bearer ${res.locals.oauth.token.jwt}`);
107-
106+
// res.set('Authorization', `Bearer ${res.locals.oauth.token.jwt}`);
107+
return null;
108108
// next();
109109
});
110110
},

routes/user.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const debug = require('debug')('route:user');
22
const swagger = require('@cesine/swagger-node-express');
3-
const param = require('@cesine/swagger-node-express/Common/node/paramTypes.js');
3+
const param = require('@cesine/swagger-node-express/Common/node/paramTypes');
44

55
const User = require('../models/user');
66
const authenticationMiddleware = require('../middleware/authentication');
@@ -29,11 +29,11 @@ exports.getUser = {
2929
username: req.params.username,
3030
};
3131

32-
User.read(json, (readErr, profile) => {
32+
return User.read(json, (readErr, profile) => {
3333
if (readErr) {
3434
return next(readErr, req, res, next);
3535
}
36-
res.json(profile);
36+
return res.json(profile);
3737
});
3838
});
3939
},
@@ -60,7 +60,7 @@ exports.getCurrentUser = {
6060
username: res.locals.user.username,
6161
};
6262

63-
User.read(json, (readErr, profile) => {
63+
return User.read(json, (readErr, profile) => {
6464
if (readErr) {
6565
return next(readErr, req, res, next);
6666
}
@@ -70,8 +70,10 @@ exports.getCurrentUser = {
7070
notFound.status = 404;
7171
return next(notFound);
7272
}
73-
profile.token = res.locals.token;
74-
res.json(profile);
73+
return res.json({
74+
...profile,
75+
token: res.locals.token,
76+
});
7577
});
7678
});
7779
},
@@ -100,7 +102,7 @@ exports.getList = {
100102
if (err) {
101103
return next(err, req, res, next);
102104
}
103-
res.json(miniProfiles);
105+
return res.json(miniProfiles);
104106
});
105107
},
106108
};
@@ -154,11 +156,11 @@ exports.putUser = {
154156
}
155157

156158
req.body.username = res.locals.user.username;
157-
User.save(req.body, (saveErr, profile) => {
159+
return User.save(req.body, (saveErr, profile) => {
158160
if (saveErr) {
159161
return next(saveErr, req, res, next);
160162
}
161-
res.json(profile);
163+
return res.json(profile);
162164
});
163165
});
164166
},

routes/utterances.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* Load modules provided by $ npm install, see package.json for details */
22
const swagger = require('@cesine/swagger-node-express');
3-
const param = require('../node_modules/@cesine/swagger-node-express/Common/node/paramTypes.js');
4-
const appVersion = require('../package.json').version;
3+
const param = require('../node_modules/@cesine/swagger-node-express/Common/node/paramTypes');
54

65
exports.getUtterances = {
76
spec: {

0 commit comments

Comments
 (0)