Skip to content

Commit

Permalink
Dev Tooling fixes (eslint/editorconfig) (glitch-soc#1398)
Browse files Browse the repository at this point in the history
* Add eslint to dev dependancies so it gets installed for the repo

yarn add --dev eslint babel-eslint eslint-plugin-reac

project specific version of eslint, you can globally install eslint-cli
if you want the global runtime, or add .bin to your path

* fix eslint errors about inconsitent returns

* eslint ignore the same as git ignore. allows for eslint .

* Add editorconfig file so everyones editor will be setup to follow the same standards
  • Loading branch information
halkeye authored and Gargron committed Apr 10, 2017
1 parent 3fd5385 commit 3672a79
Show file tree
Hide file tree
Showing 5 changed files with 529 additions and 19 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
@@ -0,0 +1,12 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
30 changes: 30 additions & 0 deletions .eslintignore
@@ -0,0 +1,30 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
/tmp
coverage
public/system
public/assets
.env
.env.production
node_modules/
neo4j/

# Ignore Vagrant files
.vagrant/

# Ignore Capistrano customizations
config/deploy/*
5 changes: 5 additions & 0 deletions package.json
Expand Up @@ -72,5 +72,10 @@
"webpack": "^2.2.1",
"websocket.js": "^0.1.7",
"ws": "^2.1.0"
},
"devDependencies": {
"babel-eslint": "^7.2.1",
"eslint": "^3.19.0",
"eslint-plugin-react": "^6.10.3"
}
}
15 changes: 10 additions & 5 deletions streaming/index.js
Expand Up @@ -87,21 +87,24 @@ const setRequestId = (req, res, next) => {
const accountFromToken = (token, req, next) => {
pgPool.connect((err, client, done) => {
if (err) {
return next(err)
next(err)
return
}

client.query('SELECT oauth_access_tokens.resource_owner_id, users.account_id FROM oauth_access_tokens INNER JOIN users ON oauth_access_tokens.resource_owner_id = users.id WHERE oauth_access_tokens.token = $1 LIMIT 1', [token], (err, result) => {
done()

if (err) {
return next(err)
next(err)
return
}

if (result.rows.length === 0) {
err = new Error('Invalid access token')
err.statusCode = 401

return next(err)
next(err)
return
}

req.accountId = result.rows[0].account_id
Expand All @@ -113,7 +116,8 @@ const accountFromToken = (token, req, next) => {

const authenticationMiddleware = (req, res, next) => {
if (req.method === 'OPTIONS') {
return next()
next()
return
}

const authorization = req.get('Authorization')
Expand All @@ -122,7 +126,8 @@ const authenticationMiddleware = (req, res, next) => {
const err = new Error('Missing access token')
err.statusCode = 401

return next(err)
next(err)
return
}

const token = authorization.replace(/^Bearer /, '')
Expand Down

0 comments on commit 3672a79

Please sign in to comment.