This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component, PropTypes } from 'react'; | |
| import $ from 'jquery'; | |
| const BUMP_URL = (id) => `/bump/${id}`; | |
| export default class Avatar extends Component { | |
| static props = { | |
| userId: PropTypes.string.isRequired, | |
| name: PropTypes.string.isRequired, | |
| avatar_url: PropTypes.string.isRequired, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import initStoryshots from 'storyshots'; | |
| initStoryshots(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const resolvers = { | |
| TypeName: { | |
| resolver(doc, args, { user }) { | |
| if (!user || !user.admin) { | |
| throw new Error("Admin access required"); | |
| } | |
| /* original implementation */ | |
| }, | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const onLogin = async function(serverUrl, email, password) { | |
| const response = await fetch(`${serverUrl}/login`, { | |
| method: 'POST', | |
| body: JSON.stringify({ email, password }), | |
| headers: { 'Content-Type': 'application/json' }, | |
| }); | |
| const data = await response.json(); | |
| token = data.token; | |
| localStorage.setItem(KEY, token); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const resolvers = { | |
| /* ... */ | |
| Query: { | |
| /* ... */ | |
| me(root, args, { user }) { | |
| return user; | |
| }, | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extend type Query { | |
| users(lastCreatedAt: Float, limit: Int): [User!] | |
| user(id: ObjID!): User | |
| me: User | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This is a hard-coded value obtained via cURL, but in a real app | |
| // you would read this from local storage (with localStorage.getItem(..)) | |
| // and set it on the `onLogin` handler. | |
| let token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VySWQiOiI1OGNlMThmNTAyMjZiODZlYmY4YTNjN2UifQ.94L8T58sxT4QHEduQnYVl_V3JrT0E6eGwrEJyu_0BDo"; | |
| const networkInterface = createNetworkInterface({ | |
| uri: `${REACT_APP_API_HOST}/graphql`, | |
| }); | |
| networkInterface.use([ | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mutation { | |
| createUser(input:{ | |
| email: "[email protected]", | |
| password: "testpassword", | |
| hasGitHubToken:false, | |
| hasTrelloToken: false | |
| }) { | |
| id | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bcrypt from 'bcrypt'; | |
| const SALT_ROUNDS = 10; | |
| export default class User { | |
| /* ... */ | |
| async insert(doc) { | |
| const { password, ...rest } = doc; | |
| const hash = await bcrypt.hash(password, SALT_ROUNDS); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| input CreateUserInput { | |
| email: String! | |
| password: String! | |
| hasGitHubToken: Boolean! | |
| hasTrelloToken: Boolean! | |
| } |