Skip to content

Commit db03bcf

Browse files
committed
Linted
1 parent 3f2968a commit db03bcf

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

Diff for: src/http/get-login/github.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
let tiny = require('tiny-json-http')
22

3-
module.exports = async function github(req) {
3+
module.exports = async function github (req) {
44

55
// trade the code for an access token
66
let result = await tiny.post({
77
url: 'https://github.com/login/oauth/access_token',
8-
headers: {Accept: 'application/json'},
8+
headers: { accept: 'application/json' },
99
data: {
1010
code: req.query.code,
1111
client_id: process.env.GITHUB_CLIENT_ID,
@@ -19,7 +19,7 @@ module.exports = async function github(req) {
1919
// use the access token to get the user account
2020
let user = await tiny.get({
2121
url: `https://api.github.com/user?access_token=${token}`,
22-
headers: {Accept: 'application/json'},
22+
headers: { accept: 'application/json' },
2323
})
2424

2525
// create a clean acccount obj

Diff for: src/http/get-login/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
let arc = require('@architect/functions')
22
let github = require('./github')
33

4-
async function login(req) {
4+
async function login (req) {
55
if (req.query.code) {
66
let account = await github(req)
77
return {
8-
session: {account},
8+
session: { account },
99
location: '/'
1010
}
1111
}

Diff for: src/http/post-graphql/middleware/auth.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// mutations require req.session.account
2-
module.exports = async function auth(req) {
2+
module.exports = async function auth (req) {
33

44
let client_id = process.env.GITHUB_CLIENT_ID
55
let redirect_uri = process.env.GITHUB_REDIRECT

Diff for: src/http/post-graphql/middleware/query.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@ let { account, draft, drafts, save, destroy } = require('../resolvers')
1111
let typeDefs = fs.readFileSync(path.join(__dirname, '..', 'schema.graphql')).toString()
1212

1313
// 3. combine resolvers and schema
14-
let schema = makeExecutableSchema({
15-
typeDefs,
14+
let schema = makeExecutableSchema({
15+
typeDefs,
1616
resolvers: {
1717
Query: { draft, drafts },
1818
Mutation: { account, save, destroy }
1919
}
2020
})
2121

2222
/** graphql middleware */
23-
module.exports = async function query(req) {
23+
module.exports = async function query (req) {
2424
try {
25-
let result = await graphql(schema, req.body.query, {}, req.session, req.body.variables, req.body.operationName)
26-
return {
25+
let result = await graphql(schema, req.body.query, {}, req.session, req.body.variables, req.body.operationName)
26+
return {
2727
json: result
2828
}
2929
}
30-
catch(e) {
31-
return {
30+
catch (e) {
31+
return {
3232
json: { error: e.name, message: e.message, stack: e.stack }
3333
}
3434
}

Diff for: src/http/post-graphql/resolvers.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@ module.exports = {
99
destroy
1010
}
1111

12-
async function account(root, args, session) {
12+
async function account (root, args, session) {
1313
if (!session.account)
1414
throw Error('not authorized')
1515
let copy = session.account
1616
delete copy.token
1717
return copy
1818
}
1919

20-
async function draft(root, args, session) {
21-
return await data.get({
22-
table: 'drafts',
20+
async function draft (root, args) {
21+
return data.get({
22+
table: 'drafts',
2323
...args
2424
})
2525
}
2626

27-
async function drafts(root, args, session) {
28-
return await data.get({
29-
table: 'drafts',
27+
async function drafts () {
28+
return data.get({
29+
table: 'drafts',
3030
})
3131
}
3232

33-
async function save(root, draft, session) {
33+
async function save (root, draft, session) {
3434
if (!session.account)
3535
throw Error('not authorized')
36-
let required = ['title', 'body']//, 'author', 'avatar']
36+
let required = [ 'title', 'body' ]// , 'author', 'avatar']
3737
for (let param of required) {
3838
if (!draft[param])
3939
throw ReferenceError(`missing param ${param}`)
@@ -44,17 +44,17 @@ async function save(root, draft, session) {
4444
draft.avatar = session.account.avatar
4545
draft.title = xss(draft.title)
4646
draft.body = xss(draft.body)
47-
return await data.set({
48-
table: 'drafts',
47+
return data.set({
48+
table: 'drafts',
4949
...draft
5050
})
5151
}
5252

53-
async function destroy(root, draft, session) {
53+
async function destroy (root, draft, session) {
5454
if (!session.account)
5555
throw Error('not authorized')
56-
return await data.destroy({
57-
table: 'drafts',
56+
return data.destroy({
57+
table: 'drafts',
5858
...draft
5959
})
6060
}

Diff for: src/http/post-logout/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let arc = require('@architect/functions')
22

3-
async function logout(req) {
3+
async function logout () {
44
return {
55
session: {},
66
location: '/'

0 commit comments

Comments
 (0)