diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-01-30 12:41:01 -0500 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-01-30 12:41:01 -0500 |
| commit | cd0b07b3adb36fb5ec098f9e511ab45d774fee7b (patch) | |
| tree | a203e5010219ccea1acc6bbd2c0a4bcfa0a78615 | |
| parent | 0a1648bf47490b312169c531aeb51ef4725e8d2e (diff) | |
Move to Prisma Backend
| -rw-r--r-- | backend/.gitignore | 7 | ||||
| -rw-r--r-- | backend/.graphqlconfig.yml | 10 | ||||
| -rw-r--r-- | backend/README.md | 1 | ||||
| -rw-r--r-- | backend/database/datamodel.graphql | 26 | ||||
| -rw-r--r-- | backend/database/prisma.yml | 21 | ||||
| -rw-r--r-- | backend/database/seed.graphql | 24 | ||||
| -rw-r--r-- | backend/package.json | 22 | ||||
| -rw-r--r-- | backend/src/generated/prisma.graphql | 615 | ||||
| -rw-r--r-- | backend/src/index.js | 33 | ||||
| -rw-r--r-- | backend/src/resolvers/AuthPayload.js | 7 | ||||
| -rw-r--r-- | backend/src/resolvers/Mutation.js | 104 | ||||
| -rw-r--r-- | backend/src/resolvers/Query.js | 31 | ||||
| -rw-r--r-- | backend/src/schema.graphql | 36 | ||||
| -rw-r--r-- | backend/src/utils.js | 23 | ||||
| -rw-r--r-- | frontend/.babelrc (renamed from .babelrc) | 0 | ||||
| -rw-r--r-- | frontend/.env (renamed from .env) | 0 | ||||
| -rw-r--r-- | frontend/README.md (renamed from README.md) | 0 | ||||
| -rw-r--r-- | frontend/components/AddToCart.js (renamed from components/AddToCart.js) | 0 | ||||
| -rw-r--r-- | frontend/components/Cart.js (renamed from components/Cart.js) | 0 | ||||
| -rw-r--r-- | frontend/components/CartList.js (renamed from components/CartList.js) | 0 | ||||
| -rw-r--r-- | frontend/components/ChaChing.js (renamed from components/ChaChing.js) | 0 | ||||
| -rw-r--r-- | frontend/components/Count.js (renamed from components/Count.js) | 0 | ||||
| -rw-r--r-- | frontend/components/CreateItem.js (renamed from components/CreateItem.js) | 0 | ||||
| -rw-r--r-- | frontend/components/ErrorMessage.js (renamed from components/ErrorMessage.js) | 0 | ||||
| -rw-r--r-- | frontend/components/Header.js (renamed from components/Header.js) | 0 | ||||
| -rw-r--r-- | frontend/components/Item.js (renamed from components/Item.js) | 0 | ||||
| -rw-r--r-- | frontend/components/Items.js (renamed from components/Items.js) | 0 | ||||
| -rw-r--r-- | frontend/components/LoginAuth0.js (renamed from components/LoginAuth0.js) | 0 | ||||
| -rw-r--r-- | frontend/components/Meta.js (renamed from components/Meta.js) | 0 | ||||
| -rw-r--r-- | frontend/components/Nav.js (renamed from components/Nav.js) | 0 | ||||
| -rw-r--r-- | frontend/components/OrderList.js (renamed from components/OrderList.js) | 0 | ||||
| -rw-r--r-- | frontend/components/Page.js (renamed from components/Page.js) | 0 | ||||
| -rw-r--r-- | frontend/components/Pagination.js (renamed from components/Pagination.js) | 0 | ||||
| -rw-r--r-- | frontend/components/Search.js (renamed from components/Search.js) | 0 | ||||
| -rw-r--r-- | frontend/components/Signup.js (renamed from components/Signup.js) | 0 | ||||
| -rw-r--r-- | frontend/components/SingleItem.js (renamed from components/SingleItem.js) | 0 | ||||
| -rw-r--r-- | frontend/components/TakeMyMoney.js (renamed from components/TakeMyMoney.js) | 0 | ||||
| -rw-r--r-- | frontend/components/UpdateItem.js (renamed from components/UpdateItem.js) | 0 | ||||
| -rw-r--r-- | frontend/config.js (renamed from config.js) | 0 | ||||
| -rw-r--r-- | frontend/enhancers.js (renamed from enhancers.js) | 0 | ||||
| -rw-r--r-- | frontend/lib/formatMoney.js (renamed from lib/formatMoney.js) | 0 | ||||
| -rw-r--r-- | frontend/lib/image.js (renamed from lib/image.js) | 0 | ||||
| -rw-r--r-- | frontend/lib/initApollo.js (renamed from lib/initApollo.js) | 0 | ||||
| -rw-r--r-- | frontend/lib/withData.js (renamed from lib/withData.js) | 0 | ||||
| -rw-r--r-- | frontend/notes.md (renamed from notes.md) | 0 | ||||
| -rw-r--r-- | frontend/package-lock.json (renamed from package-lock.json) | 0 | ||||
| -rw-r--r-- | frontend/package.json (renamed from package.json) | 0 | ||||
| -rw-r--r-- | frontend/pages/add.js (renamed from pages/add.js) | 0 | ||||
| -rw-r--r-- | frontend/pages/admin/update.js (renamed from pages/admin/update.js) | 0 | ||||
| -rw-r--r-- | frontend/pages/buy.js (renamed from pages/buy.js) | 0 | ||||
| -rw-r--r-- | frontend/pages/cart.js (renamed from pages/cart.js) | 0 | ||||
| -rw-r--r-- | frontend/pages/index.js (renamed from pages/index.js) | 0 | ||||
| -rw-r--r-- | frontend/pages/item.js (renamed from pages/item.js) | 0 | ||||
| -rw-r--r-- | frontend/pages/items.js (renamed from pages/items.js) | 0 | ||||
| -rw-r--r-- | frontend/pages/orders.js (renamed from pages/orders.js) | 0 | ||||
| -rw-r--r-- | frontend/pages/signup.js (renamed from pages/signup.js) | 0 | ||||
| -rw-r--r-- | frontend/queries/fragments.js (renamed from queries/fragments.js) | 0 | ||||
| -rw-r--r-- | frontend/queries/index.js (renamed from queries/index.js) | 0 | ||||
| -rw-r--r-- | frontend/queries/mutations.js (renamed from queries/mutations.js) | 0 | ||||
| -rw-r--r-- | frontend/routes.js (renamed from routes.js) | 0 | ||||
| -rw-r--r-- | frontend/server.js (renamed from server.js) | 0 | ||||
| -rw-r--r-- | frontend/src/auth0/auth0Authentication.graphql (renamed from src/auth0/auth0Authentication.graphql) | 0 | ||||
| -rw-r--r-- | frontend/src/auth0/auth0Authentication.js (renamed from src/auth0/auth0Authentication.js) | 0 | ||||
| -rw-r--r-- | frontend/static/nprogress.css (renamed from static/nprogress.css) | 0 | ||||
| -rw-r--r-- | graphcool-old/.graphcoolrc | 3 | ||||
| -rw-r--r-- | graphcool-old/graphcool.yml | 56 | ||||
| -rw-r--r-- | graphcool-old/package-lock.json | 790 | ||||
| -rw-r--r-- | graphcool-old/package.json | 18 | ||||
| -rw-r--r-- | graphcool-old/project.graphcool | 52 | ||||
| -rw-r--r-- | graphcool-old/src/auth0/auth0Authentication.graphql | 8 | ||||
| -rw-r--r-- | graphcool-old/src/auth0/auth0Authentication.js | 100 | ||||
| -rw-r--r-- | graphcool-old/src/createCharge.js | 52 | ||||
| -rw-r--r-- | graphcool-old/src/createCharge.test.js | 23 | ||||
| -rw-r--r-- | graphcool-old/src/getPrice.js | 26 | ||||
| -rw-r--r-- | graphcool-old/src/hello.graphql | 7 | ||||
| -rw-r--r-- | graphcool-old/src/hello.js | 11 | ||||
| -rw-r--r-- | graphcool-old/src/index.js | 2 | ||||
| -rw-r--r-- | graphcool-old/types.graphql | 56 | ||||
| -rw-r--r-- | graphcool/.graphcoolrc | 4 | ||||
| -rw-r--r-- | graphcool/graphcool.yml | 44 | ||||
| -rw-r--r-- | graphcool/package-lock.json | 39 | ||||
| -rw-r--r-- | graphcool/package.json | 8 | ||||
| -rw-r--r-- | graphcool/src/createCharge.js | 52 | ||||
| -rw-r--r-- | graphcool/src/createCharge.test.js | 23 | ||||
| -rw-r--r-- | graphcool/src/getPrice.js | 26 | ||||
| -rw-r--r-- | graphcool/src/hello.graphql | 7 | ||||
| -rw-r--r-- | graphcool/src/hello.js | 11 | ||||
| -rw-r--r-- | graphcool/src/index.js | 2 | ||||
| -rw-r--r-- | graphcool/types.graphql | 53 |
89 files changed, 960 insertions, 1473 deletions
diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..0f79d10 --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,7 @@ +dist +package-lock.json +node_modules +.idea +.vscode +*.log +.env* diff --git a/backend/.graphqlconfig.yml b/backend/.graphqlconfig.yml new file mode 100644 index 0000000..b495937 --- /dev/null +++ b/backend/.graphqlconfig.yml @@ -0,0 +1,10 @@ +projects: + app: + schemaPath: "src/schema.graphql" + extensions: + endpoints: + default: "http://localhost:4000" + database: + schemaPath: "src/generated/prisma.graphql" + extensions: + prisma: database/prisma.yml
\ No newline at end of file diff --git a/backend/README.md b/backend/README.md new file mode 100644 index 0000000..4acc044 --- /dev/null +++ b/backend/README.md @@ -0,0 +1 @@ +What are all these files?! diff --git a/backend/database/datamodel.graphql b/backend/database/datamodel.graphql new file mode 100644 index 0000000..605e242 --- /dev/null +++ b/backend/database/datamodel.graphql @@ -0,0 +1,26 @@ +type Post { + id: ID! @unique + createdAt: DateTime! + updatedAt: DateTime! + isPublished: Boolean! @default(value: "false") + title: String! + text: String! + author: User! +} + +type User { + id: ID! @unique + email: String! @unique + password: String! + name: String! + posts: [Post!]! + website: String + age: Int +} + +type Item { + id: ID! @unique + title: String! + description: String! + price: Int! +} diff --git a/backend/database/prisma.yml b/backend/database/prisma.yml new file mode 100644 index 0000000..6570be2 --- /dev/null +++ b/backend/database/prisma.yml @@ -0,0 +1,21 @@ +# the name for the service (will be part of the service's HTTP endpoint) +service: my-own + +# the cluster and stage the service is deployed to +stage: ${env:PRISMA_STAGE} + +# to disable authentication: +# disableAuth: true +secret: ${env:PRISMA_SECRET} + +# the file path pointing to your data model +datamodel: datamodel.graphql + +# uncomment the following two lines to seed your service with initial data +# seed: +# import: seed.graphql + +cluster: ${env:PRISMA_CLUSTER} + + +disableAuth: true
\ No newline at end of file diff --git a/backend/database/seed.graphql b/backend/database/seed.graphql new file mode 100644 index 0000000..5779328 --- /dev/null +++ b/backend/database/seed.graphql @@ -0,0 +1,24 @@ +mutation { + createUser(data: { + email: "developer@example.com" + password: "$2a$10$hACwQ5/HQI6FhbIISOUVeusy3sKyUDhSq36fF5d/54aAdiygJPFzm" # plaintext password: "nooneknows" + name: "Sarah" + posts: { + create: [{ + title: "Hello World" + text: "This is my first blog post ever!" + isPublished: true + }, { + title: "My Second Post" + text: "My first post was good, but this one is better!" + isPublished: true + }, { + title: "Solving World Hunger" + text: "This is a draft..." + isPublished: false + }] + } + }) { + id + } +}
\ No newline at end of file diff --git a/backend/package.json b/backend/package.json new file mode 100644 index 0000000..ca26206 --- /dev/null +++ b/backend/package.json @@ -0,0 +1,22 @@ +{ + "name": "my-own", + "scripts": { + "start": "nodemon -e js,graphql -x node -r dotenv/config src/index.js", + "debug": "nodemon -e js,graphql -x node --inspect -r dotenv/config src/index.js", + "playground": "graphql playground", + "dev": "npm-run-all --parallel start playground" + }, + "dependencies": { + "bcryptjs": "2.4.3", + "graphql-yoga": "1.2.1", + "jsonwebtoken": "8.1.1", + "prisma-binding": "1.4.0" + }, + "devDependencies": { + "dotenv": "4.0.0", + "graphql-cli": "2.13.0", + "nodemon": "1.14.11", + "npm-run-all": "4.1.2", + "prisma": "1.0.11" + } +} diff --git a/backend/src/generated/prisma.graphql b/backend/src/generated/prisma.graphql new file mode 100644 index 0000000..50aaa97 --- /dev/null +++ b/backend/src/generated/prisma.graphql @@ -0,0 +1,615 @@ +# THIS FILE HAS BEEN AUTO-GENERATED BY "PRISMA DEPLOY" +# DO NOT EDIT THIS FILE DIRECTLY + +# +# Model Types +# + +type Item implements Node { + id: ID! + title: String! + description: String! + price: Int! +} + +type Post implements Node { + id: ID! + createdAt: DateTime! + updatedAt: DateTime! + isPublished: Boolean! + title: String! + text: String! + author(where: UserWhereInput): User! +} + +type User implements Node { + id: ID! + email: String! + password: String! + name: String! + posts(where: PostWhereInput, orderBy: PostOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Post!] + website: String + age: Int +} + + +# +# Other Types +# + +type AggregateItem { + count: Int! +} + +type AggregatePost { + count: Int! +} + +type AggregateUser { + count: Int! +} + +type BatchPayload { + count: Long! +} + +scalar DateTime + +type ItemConnection { + pageInfo: PageInfo! + edges: [ItemEdge]! + aggregate: AggregateItem! +} + +input ItemCreateInput { + title: String! + description: String! + price: Int! +} + +type ItemEdge { + node: Item! + cursor: String! +} + +enum ItemOrderByInput { + id_ASC + id_DESC + title_ASC + title_DESC + description_ASC + description_DESC + price_ASC + price_DESC + updatedAt_ASC + updatedAt_DESC + createdAt_ASC + createdAt_DESC +} + +type ItemPreviousValues { + id: ID! + title: String! + description: String! + price: Int! +} + +type ItemSubscriptionPayload { + mutation: MutationType! + node: Item + updatedFields: [String!] + previousValues: ItemPreviousValues +} + +input ItemSubscriptionWhereInput { + AND: [ItemSubscriptionWhereInput!] + OR: [ItemSubscriptionWhereInput!] + mutation_in: [MutationType!] + updatedFields_contains: String + updatedFields_contains_every: [String!] + updatedFields_contains_some: [String!] + node: ItemWhereInput +} + +input ItemUpdateInput { + title: String + description: String + price: Int +} + +input ItemWhereInput { + AND: [ItemWhereInput!] + OR: [ItemWhereInput!] + id: ID + id_not: ID + id_in: [ID!] + id_not_in: [ID!] + id_lt: ID + id_lte: ID + id_gt: ID + id_gte: ID + id_contains: ID + id_not_contains: ID + id_starts_with: ID + id_not_starts_with: ID + id_ends_with: ID + id_not_ends_with: ID + title: String + title_not: String + title_in: [String!] + title_not_in: [String!] + title_lt: String + title_lte: String + title_gt: String + title_gte: String + title_contains: String + title_not_contains: String + title_starts_with: String + title_not_starts_with: String + title_ends_with: String + title_not_ends_with: String + description: String + description_not: String + description_in: [String!] + description_not_in: [String!] + description_lt: String + description_lte: String + description_gt: String + description_gte: String + description_contains: String + description_not_contains: String + description_starts_with: String + description_not_starts_with: String + description_ends_with: String + description_not_ends_with: String + price: Int + price_not: Int + price_in: [Int!] + price_not_in: [Int!] + price_lt: Int + price_lte: Int + price_gt: Int + price_gte: Int +} + +input ItemWhereUniqueInput { + id: ID +} + +scalar Long + +type Mutation { + createPost(data: PostCreateInput!): Post! + createUser(data: UserCreateInput!): User! + createItem(data: ItemCreateInput!): Item! + updatePost(data: PostUpdateInput!, where: PostWhereUniqueInput!): Post + updateUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User + updateItem(data: ItemUpdateInput!, where: ItemWhereUniqueInput!): Item + deletePost(where: PostWhereUniqueInput!): Post + deleteUser(where: UserWhereUniqueInput!): User + deleteItem(where: ItemWhereUniqueInput!): Item + upsertPost(where: PostWhereUniqueInput!, create: PostCreateInput!, update: PostUpdateInput!): Post! + upsertUser(where: UserWhereUniqueInput!, create: UserCreateInput!, update: UserUpdateInput!): User! + upsertItem(where: ItemWhereUniqueInput!, create: ItemCreateInput!, update: ItemUpdateInput!): Item! + updateManyPosts(data: PostUpdateInput!, where: PostWhereInput!): BatchPayload! + updateManyUsers(data: UserUpdateInput!, where: UserWhereInput!): BatchPayload! + updateManyItems(data: ItemUpdateInput!, where: ItemWhereInput!): BatchPayload! + deleteManyPosts(where: PostWhereInput!): BatchPayload! + deleteManyUsers(where: UserWhereInput!): BatchPayload! + deleteManyItems(where: ItemWhereInput!): BatchPayload! +} + +enum MutationType { + CREATED + UPDATED + DELETED +} + +interface Node { + id: ID! +} + +type PageInfo { + hasNextPage: Boolean! + hasPreviousPage: Boolean! + startCursor: String + endCursor: String +} + +type PostConnection { + pageInfo: PageInfo! + edges: [PostEdge]! + aggregate: AggregatePost! +} + +input PostCreateInput { + isPublished: Boolean + title: String! + text: String! + author: UserCreateOneWithoutPostsInput! +} + +input PostCreateManyWithoutAuthorInput { + create: [PostCreateWithoutAuthorInput!] + connect: [PostWhereUniqueInput!] +} + +input PostCreateWithoutAuthorInput { + isPublished: Boolean + title: String! + text: String! +} + +type PostEdge { + node: Post! + cursor: String! +} + +enum PostOrderByInput { + id_ASC + id_DESC + createdAt_ASC + createdAt_DESC + updatedAt_ASC + updatedAt_DESC + isPublished_ASC + isPublished_DESC + title_ASC + title_DESC + text_ASC + text_DESC +} + +type PostPreviousValues { + id: ID! + createdAt: DateTime! + updatedAt: DateTime! + isPublished: Boolean! + title: String! + text: String! +} + +type PostSubscriptionPayload { + mutation: MutationType! + node: Post + updatedFields: [String!] + previousValues: PostPreviousValues +} + +input PostSubscriptionWhereInput { + AND: [PostSubscriptionWhereInput!] + OR: [PostSubscriptionWhereInput!] + mutation_in: [MutationType!] + updatedFields_contains: String + updatedFields_contains_every: [String!] + updatedFields_contains_some: [String!] + node: PostWhereInput +} + +input PostUpdateInput { + isPublished: Boolean + title: String + text: String + author: UserUpdateOneWithoutPostsInput +} + +input PostUpdateManyWithoutAuthorInput { + create: [PostCreateWithoutAuthorInput!] + connect: [PostWhereUniqueInput!] + disconnect: [PostWhereUniqueInput!] + delete: [PostWhereUniqueInput!] + update: [PostUpdateWithoutAuthorInput!] + upsert: [PostUpsertWithoutAuthorInput!] +} + +input PostUpdateWithoutAuthorDataInput { + isPublished: Boolean + title: String + text: String +} + +input PostUpdateWithoutAuthorInput { + where: PostWhereUniqueInput! + data: PostUpdateWithoutAuthorDataInput! +} + +input PostUpsertWithoutAuthorInput { + where: PostWhereUniqueInput! + update: PostUpdateWithoutAuthorDataInput! + create: PostCreateWithoutAuthorInput! +} + +input PostWhereInput { + AND: [PostWhereInput!] + OR: [PostWhereInput!] + id: ID + id_not: ID + id_in: [ID!] + id_not_in: [ID!] + id_lt: ID + id_lte: ID + id_gt: ID + id_gte: ID + id_contains: ID + id_not_contains: ID + id_starts_with: ID + id_not_starts_with: ID + id_ends_with: ID + id_not_ends_with: ID + createdAt: DateTime + createdAt_not: DateTime + createdAt_in: [DateTime!] + createdAt_not_in: [DateTime!] + createdAt_lt: DateTime + createdAt_lte: DateTime + createdAt_gt: DateTime + createdAt_gte: DateTime + updatedAt: DateTime + updatedAt_not: DateTime + updatedAt_in: [DateTime!] + updatedAt_not_in: [DateTime!] + updatedAt_lt: DateTime + updatedAt_lte: DateTime + updatedAt_gt: DateTime + updatedAt_gte: DateTime + isPublished: Boolean + isPublished_not: Boolean + title: String + title_not: String + title_in: [String!] + title_not_in: [String!] + title_lt: String + title_lte: String + title_gt: String + title_gte: String + title_contains: String + title_not_contains: String + title_starts_with: String + title_not_starts_with: String + title_ends_with: String + title_not_ends_with: String + text: String + text_not: String + text_in: [String!] + text_not_in: [String!] + text_lt: String + text_lte: String + text_gt: String + text_gte: String + text_contains: String + text_not_contains: String + text_starts_with: String + text_not_starts_with: String + text_ends_with: String + text_not_ends_with: String + author: UserWhereInput +} + +input PostWhereUniqueInput { + id: ID +} + +type Query { + posts(where: PostWhereInput, orderBy: PostOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Post]! + users(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [User]! + items(where: ItemWhereInput, orderBy: ItemOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Item]! + post(where: PostWhereUniqueInput!): Post + user(where: UserWhereUniqueInput!): User + item(where: ItemWhereUniqueInput!): Item + postsConnection(where: PostWhereInput, orderBy: PostOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): PostConnection! + usersConnection(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): UserConnection! + itemsConnection(where: ItemWhereInput, orderBy: ItemOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): ItemConnection! + node(id: ID!): Node +} + +type Subscription { + post(where: PostSubscriptionWhereInput): PostSubscriptionPayload + user(where: UserSubscriptionWhereInput): UserSubscriptionPayload + item(where: ItemSubscriptionWhereInput): ItemSubscriptionPayload +} + +type UserConnection { + pageInfo: PageInfo! + edges: [UserEdge]! + aggregate: AggregateUser! +} + +input UserCreateInput { + email: String! + password: String! + name: String! + website: String + age: Int + posts: PostCreateManyWithoutAuthorInput +} + +input UserCreateOneWithoutPostsInput { + create: UserCreateWithoutPostsInput + connect: UserWhereUniqueInput +} + +input UserCreateWithoutPostsInput { + email: String! + password: String! + name: String! + website: String + age: Int +} + +type UserEdge { + node: User! + cursor: String! +} + +enum UserOrderByInput { + id_ASC + id_DESC + email_ASC + email_DESC + password_ASC + password_DESC + name_ASC + name_DESC + website_ASC + website_DESC + age_ASC + age_DESC + updatedAt_ASC + updatedAt_DESC + createdAt_ASC + createdAt_DESC +} + +type UserPreviousValues { + id: ID! + email: String! + password: String! + name: String! + website: String + age: Int +} + +type UserSubscriptionPayload { + mutation: MutationType! + node: User + updatedFields: [String!] + previousValues: UserPreviousValues +} + +input UserSubscriptionWhereInput { + AND: [UserSubscriptionWhereInput!] + OR: [UserSubscriptionWhereInput!] + mutation_in: [MutationType!] + updatedFields_contains: String + updatedFields_contains_every: [String!] + updatedFields_contains_some: [String!] + node: UserWhereInput +} + +input UserUpdateInput { + email: String + password: String + name: String + website: String + age: Int + posts: PostUpdateManyWithoutAuthorInput +} + +input UserUpdateOneWithoutPostsInput { + create: UserCreateWithoutPostsInput + connect: UserWhereUniqueInput + disconnect: UserWhereUniqueInput + delete: UserWhereUniqueInput + update: UserUpdateWithoutPostsInput + upsert: UserUpsertWithoutPostsInput +} + +input UserUpdateWithoutPostsDataInput { + email: String + password: String + name: String + website: String + age: Int +} + +input UserUpdateWithoutPostsInput { + where: UserWhereUniqueInput! + data: UserUpdateWithoutPostsDataInput! +} + +input UserUpsertWithoutPostsInput { + where: UserWhereUniqueInput! + update: UserUpdateWithoutPostsDataInput! + create: UserCreateWithoutPostsInput! +} + +input UserWhereInput { + AND: [UserWhereInput!] + OR: [UserWhereInput!] + id: ID + id_not: ID + id_in: [ID!] + id_not_in: [ID!] + id_lt: ID + id_lte: ID + id_gt: ID + id_gte: ID + id_contains: ID + id_not_contains: ID + id_starts_with: ID + id_not_starts_with: ID + id_ends_with: ID + id_not_ends_with: ID + email: String + email_not: String + email_in: [String!] + email_not_in: [String!] + email_lt: String + email_lte: String + email_gt: String + email_gte: String + email_contains: String + email_not_contains: String + email_starts_with: String + email_not_starts_with: String + email_ends_with: String + email_not_ends_with: String + password: String + password_not: String + password_in: [String!] + password_not_in: [String!] + password_lt: String + password_lte: String + password_gt: String + password_gte: String + password_contains: String + password_not_contains: String + password_starts_with: String + password_not_starts_with: String + password_ends_with: String + password_not_ends_with: String + name: String + name_not: String + name_in: [String!] + name_not_in: [String!] + name_lt: String + name_lte: String + name_gt: String + name_gte: String + name_contains: String + name_not_contains: String + name_starts_with: String + name_not_starts_with: String + name_ends_with: String + name_not_ends_with: String + website: String + website_not: String + website_in: [String!] + website_not_in: [String!] + website_lt: String + website_lte: String + website_gt: String + website_gte: String + website_contains: String + website_not_contains: String + website_starts_with: String + website_not_starts_with: String + website_ends_with: String + website_not_ends_with: String + age: Int + age_not: Int + age_in: [Int!] + age_not_in: [Int!] + age_lt: Int + age_lte: Int + age_gt: Int + age_gte: Int + posts_every: PostWhereInput + posts_some: PostWhereInput + posts_none: PostWhereInput +} + +input UserWhereUniqueInput { + id: ID + email: String +} diff --git a/backend/src/index.js b/backend/src/index.js new file mode 100644 index 0000000..c73cb74 --- /dev/null +++ b/backend/src/index.js @@ -0,0 +1,33 @@ +const { GraphQLServer } = require('graphql-yoga'); +const { Prisma } = require('prisma-binding'); + +const Mutation = require('./resolvers/Mutation'); +const Query = require('./resolvers/Query'); +const AuthPayload = require('./resolvers/AuthPayload'); + +const server = new GraphQLServer({ + typeDefs: 'src/schema.graphql', + resolvers: { + // detail resolvers + Mutation, + Query, + AuthPayload, + }, + context: req => ({ + ...req, + db: new Prisma({ + typeDefs: 'src/generated/prisma.graphql', + endpoint: process.env.PRISMA_ENDPOINT, // the endpoint of the Prisma DB service (value is set in .env) + secret: process.env.PRISMA_SECRET, // taken from database/prisma.yml (value is set in .env) + debug: true, // log all GraphQL queries & mutations + }), + }), +}); + +// This is an example of custom express middlware +server.express.use((req, res, next) => { + console.log("Hi I'm middlware"); + next(); +}); + +server.start(() => console.log('Server is running on http://localhost:4000')); diff --git a/backend/src/resolvers/AuthPayload.js b/backend/src/resolvers/AuthPayload.js new file mode 100644 index 0000000..f5945b7 --- /dev/null +++ b/backend/src/resolvers/AuthPayload.js @@ -0,0 +1,7 @@ +const { Context } = require('../utils'); + +const AuthPayload = { + user: async ({ user: { id } }, args, ctx, info) => ctx.db.query.user({ where: { id } }, info), +}; + +module.exports = AuthPayload; diff --git a/backend/src/resolvers/Mutation.js b/backend/src/resolvers/Mutation.js new file mode 100644 index 0000000..2796cf8 --- /dev/null +++ b/backend/src/resolvers/Mutation.js @@ -0,0 +1,104 @@ +const bcrypt = require('bcryptjs'); +const jwt = require('jsonwebtoken'); +const { forwardTo } = require('prisma-binding'); +const { getUserId, Context } = require('../utils'); + +const mutations = { + // Signup Mutations + async signup(parent, args, ctx, info) { + const password = await bcrypt.hash(args.password, 10); + const user = await ctx.db.mutation.createUser({ + data: { ...args, password }, + }); + + return { + token: jwt.sign({ userId: user.id }, process.env.APP_SECRET), + user, + }; + }, + + async login(parent, { email, password }, ctx, info) { + const user = await ctx.db.query.user({ where: { email } }); + if (!user) { + throw new Error(`No such user found for email: ${email}`); + } + + const valid = await bcrypt.compare(password, user.password); + if (!valid) { + throw new Error('Invalid password'); + } + + return { + token: jwt.sign({ userId: user.id }, process.env.APP_SECRET), + user, + }; + }, + + // Creation of Post Mutations + createItem: forwardTo('db'), + deleteItem: forwardTo('db'), + async createDraft(parent, { title, text }, ctx, info) { + // const userId = getUserId(ctx); + const userId = getUserId(ctx); + return ctx.db.mutation.createPost( + { + data: { + title, + text, + isPublished: false, + author: { + connect: { id: userId }, + }, + }, + }, + info + ); + }, + + async publish(parent, { id }, ctx, info) { + const userId = getUserId(ctx); + const postExists = await ctx.db.exists.Post({ + id, + author: { id: userId }, + }); + if (!postExists) { + throw new Error(`Post not found or you're not the author`); + } + + return ctx.db.mutation.updatePost( + { + where: { id }, + data: { isPublished: true }, + }, + info + ); + }, + + async deletePost(parent, { id }, ctx, info) { + const userId = getUserId(ctx); + const postExists = await ctx.db.exists.Post({ + id, + author: { id: userId }, + }); + if (!postExists) { + throw new Error(`Post not found or you're not the author`); + } + + return ctx.db.mutation.deletePost({ where: { id } }); + }, + + // Wes Added this brand new one! + async updatePost(parent, args, ctx, info) { + const updatedPost = await ctx.db.mutation.updatePost({ + where: { id: args.id }, + data: { + title: args.title, + text: args.text, + }, + }); + console.log(updatedPost); + return updatedPost; + }, +}; + +module.exports = mutations; diff --git a/backend/src/resolvers/Query.js b/backend/src/resolvers/Query.js new file mode 100644 index 0000000..9d9d142 --- /dev/null +++ b/backend/src/resolvers/Query.js @@ -0,0 +1,31 @@ +const { getUserId, Context } = require('../utils'); + +const Query = { + feed(parent, args, ctx, info) { + return ctx.db.query.posts({ where: { isPublished: true } }, info); + }, + + drafts(parent, args, ctx, info) { + const id = getUserId(ctx); + + const where = { + isPublished: false, + author: { + id, + }, + }; + + return ctx.db.query.posts({ where }, info); + }, + + post(parent, { id }, ctx, info) { + return ctx.db.query.post({ where: { id } }, info); + }, + + me(parent, args, ctx, info) { + const id = getUserId(ctx); + return ctx.db.query.user({ where: { id } }, info); + }, +}; + +module.exports = Query; diff --git a/backend/src/schema.graphql b/backend/src/schema.graphql new file mode 100644 index 0000000..788d490 --- /dev/null +++ b/backend/src/schema.graphql @@ -0,0 +1,36 @@ +# import Post, Item, ItemCreateInput from './generated/prisma.graphql' + +type Query { + feed: [Post!]! + drafts: [Post!]! + post(id: ID!): Post! + me: User +} + +# import Mutation from './generated/prisma.graphql' + +type Mutation { + signup(email: String!, password: String!, name: String!): AuthPayload! + login(email: String!, password: String!): AuthPayload! + createDraft(title: String!, text: String!): Post! + publish(id: ID!): Post! + deletePost(id: ID!): Post! + updatePost(id: ID!, title: String, text: String): Post! + createItem(data: ItemCreateInput): Item! + deleteItem(id: ID!): Item! +} + +type AuthPayload { + token: String! + user: User! +} + +# THe user definition overrides +type User { + id: ID! + email: String! + website: String + name: String! + posts: [Post!]! + age: Int +} diff --git a/backend/src/utils.js b/backend/src/utils.js new file mode 100644 index 0000000..35587db --- /dev/null +++ b/backend/src/utils.js @@ -0,0 +1,23 @@ +const jwt = require('jsonwebtoken'); + +function getUserId(ctx) { + const Authorization = ctx.request.get('Authorization'); + if (Authorization) { + const token = Authorization.replace('Bearer ', ''); + const { userId } = jwt.verify(token, process.env.APP_SECRET); + return userId; + } + + throw new AuthError(); +} + +class AuthError extends Error { + constructor() { + super('Not authorized'); + } +} + +module.exports = { + getUserId, + AuthError, +}; diff --git a/.babelrc b/frontend/.babelrc index d9c3f91..d9c3f91 100644 --- a/.babelrc +++ b/frontend/.babelrc diff --git a/README.md b/frontend/README.md index c254cc0..c254cc0 100644 --- a/README.md +++ b/frontend/README.md diff --git a/components/AddToCart.js b/frontend/components/AddToCart.js index e46a1f5..e46a1f5 100644 --- a/components/AddToCart.js +++ b/frontend/components/AddToCart.js diff --git a/components/Cart.js b/frontend/components/Cart.js index 88b072c..88b072c 100644 --- a/components/Cart.js +++ b/frontend/components/Cart.js diff --git a/components/CartList.js b/frontend/components/CartList.js index b54aa39..b54aa39 100644 --- a/components/CartList.js +++ b/frontend/components/CartList.js diff --git a/components/ChaChing.js b/frontend/components/ChaChing.js index 5874c27..5874c27 100644 --- a/components/ChaChing.js +++ b/frontend/components/ChaChing.js diff --git a/components/Count.js b/frontend/components/Count.js index 800a902..800a902 100644 --- a/components/Count.js +++ b/frontend/components/Count.js diff --git a/components/CreateItem.js b/frontend/components/CreateItem.js index 27b62e5..27b62e5 100644 --- a/components/CreateItem.js +++ b/frontend/components/CreateItem.js diff --git a/components/ErrorMessage.js b/frontend/components/ErrorMessage.js index 12de51d..12de51d 100644 --- a/components/ErrorMessage.js +++ b/frontend/components/ErrorMessage.js diff --git a/components/Header.js b/frontend/components/Header.js index cc4cca7..cc4cca7 100644 --- a/components/Header.js +++ b/frontend/components/Header.js diff --git a/components/Item.js b/frontend/components/Item.js index 1b47fcf..1b47fcf 100644 --- a/components/Item.js +++ b/frontend/components/Item.js diff --git a/components/Items.js b/frontend/components/Items.js index 053c9af..053c9af 100644 --- a/components/Items.js +++ b/frontend/components/Items.js diff --git a/components/LoginAuth0.js b/frontend/components/LoginAuth0.js index b55ae4a..b55ae4a 100644 --- a/components/LoginAuth0.js +++ b/frontend/components/LoginAuth0.js diff --git a/components/Meta.js b/frontend/components/Meta.js index d7a2e17..d7a2e17 100644 --- a/components/Meta.js +++ b/frontend/components/Meta.js diff --git a/components/Nav.js b/frontend/components/Nav.js index d1f341d..d1f341d 100644 --- a/components/Nav.js +++ b/frontend/components/Nav.js diff --git a/components/OrderList.js b/frontend/components/OrderList.js index c33f0b9..c33f0b9 100644 --- a/components/OrderList.js +++ b/frontend/components/OrderList.js diff --git a/components/Page.js b/frontend/components/Page.js index f45d421..f45d421 100644 --- a/components/Page.js +++ b/frontend/components/Page.js diff --git a/components/Pagination.js b/frontend/components/Pagination.js index dedd231..dedd231 100644 --- a/components/Pagination.js +++ b/frontend/components/Pagination.js diff --git a/components/Search.js b/frontend/components/Search.js index 0ce136e..0ce136e 100644 --- a/components/Search.js +++ b/frontend/components/Search.js diff --git a/components/Signup.js b/frontend/components/Signup.js index 57e2569..57e2569 100644 --- a/components/Signup.js +++ b/frontend/components/Signup.js diff --git a/components/SingleItem.js b/frontend/components/SingleItem.js index 297c33d..297c33d 100644 --- a/components/SingleItem.js +++ b/frontend/components/SingleItem.js diff --git a/components/TakeMyMoney.js b/frontend/components/TakeMyMoney.js index d68cca1..d68cca1 100644 --- a/components/TakeMyMoney.js +++ b/frontend/components/TakeMyMoney.js diff --git a/components/UpdateItem.js b/frontend/components/UpdateItem.js index 27be90f..27be90f 100644 --- a/components/UpdateItem.js +++ b/frontend/components/UpdateItem.js diff --git a/config.js b/frontend/config.js index c2b78cb..c2b78cb 100644 --- a/config.js +++ b/frontend/config.js diff --git a/enhancers.js b/frontend/enhancers.js index d86ca6d..d86ca6d 100644 --- a/enhancers.js +++ b/frontend/enhancers.js diff --git a/lib/formatMoney.js b/frontend/lib/formatMoney.js index edddf48..edddf48 100644 --- a/lib/formatMoney.js +++ b/frontend/lib/formatMoney.js diff --git a/lib/image.js b/frontend/lib/image.js index 5b6efb9..5b6efb9 100644 --- a/lib/image.js +++ b/frontend/lib/image.js diff --git a/lib/initApollo.js b/frontend/lib/initApollo.js index 35f5e08..35f5e08 100644 --- a/lib/initApollo.js +++ b/frontend/lib/initApollo.js diff --git a/lib/withData.js b/frontend/lib/withData.js index 0c68f49..0c68f49 100644 --- a/lib/withData.js +++ b/frontend/lib/withData.js diff --git a/notes.md b/frontend/notes.md index 3b8c1da..3b8c1da 100644 --- a/notes.md +++ b/frontend/notes.md diff --git a/package-lock.json b/frontend/package-lock.json index eed2f28..eed2f28 100644 --- a/package-lock.json +++ b/frontend/package-lock.json diff --git a/package.json b/frontend/package.json index 7cd5e70..7cd5e70 100644 --- a/package.json +++ b/frontend/package.json diff --git a/pages/add.js b/frontend/pages/add.js index 9b8c333..9b8c333 100644 --- a/pages/add.js +++ b/frontend/pages/add.js diff --git a/pages/admin/update.js b/frontend/pages/admin/update.js index ab98add..ab98add 100644 --- a/pages/admin/update.js +++ b/frontend/pages/admin/update.js diff --git a/pages/buy.js b/frontend/pages/buy.js index d6b1331..d6b1331 100644 --- a/pages/buy.js +++ b/frontend/pages/buy.js diff --git a/pages/cart.js b/frontend/pages/cart.js index afdacf7..afdacf7 100644 --- a/pages/cart.js +++ b/frontend/pages/cart.js diff --git a/pages/index.js b/frontend/pages/index.js index 24fe584..24fe584 100644 --- a/pages/index.js +++ b/frontend/pages/index.js diff --git a/pages/item.js b/frontend/pages/item.js index ad91540..ad91540 100644 --- a/pages/item.js +++ b/frontend/pages/item.js diff --git a/pages/items.js b/frontend/pages/items.js index 52f9f86..52f9f86 100644 --- a/pages/items.js +++ b/frontend/pages/items.js diff --git a/pages/orders.js b/frontend/pages/orders.js index 4025868..4025868 100644 --- a/pages/orders.js +++ b/frontend/pages/orders.js diff --git a/pages/signup.js b/frontend/pages/signup.js index f36b16f..f36b16f 100644 --- a/pages/signup.js +++ b/frontend/pages/signup.js diff --git a/queries/fragments.js b/frontend/queries/fragments.js index 019992e..019992e 100644 --- a/queries/fragments.js +++ b/frontend/queries/fragments.js diff --git a/queries/index.js b/frontend/queries/index.js index 8b7897f..8b7897f 100644 --- a/queries/index.js +++ b/frontend/queries/index.js diff --git a/queries/mutations.js b/frontend/queries/mutations.js index e69de29..e69de29 100644 --- a/queries/mutations.js +++ b/frontend/queries/mutations.js diff --git a/routes.js b/frontend/routes.js index 62f91a9..62f91a9 100644 --- a/routes.js +++ b/frontend/routes.js diff --git a/server.js b/frontend/server.js index 618dfc0..618dfc0 100644 --- a/server.js +++ b/frontend/server.js diff --git a/src/auth0/auth0Authentication.graphql b/frontend/src/auth0/auth0Authentication.graphql index 1d4b135..1d4b135 100644 --- a/src/auth0/auth0Authentication.graphql +++ b/frontend/src/auth0/auth0Authentication.graphql diff --git a/src/auth0/auth0Authentication.js b/frontend/src/auth0/auth0Authentication.js index f35cfd4..f35cfd4 100644 --- a/src/auth0/auth0Authentication.js +++ b/frontend/src/auth0/auth0Authentication.js diff --git a/static/nprogress.css b/frontend/static/nprogress.css index e18709f..e18709f 100644 --- a/static/nprogress.css +++ b/frontend/static/nprogress.css diff --git a/graphcool-old/.graphcoolrc b/graphcool-old/.graphcoolrc deleted file mode 100644 index 69adc85..0000000 --- a/graphcool-old/.graphcoolrc +++ /dev/null @@ -1,3 +0,0 @@ -targets: - Sick Fits 2: shared-eu-west-1/cj99zm6ye06sb01325ic751ww - default: Sick Fits 2 diff --git a/graphcool-old/graphcool.yml b/graphcool-old/graphcool.yml deleted file mode 100644 index eb3f085..0000000 --- a/graphcool-old/graphcool.yml +++ /dev/null @@ -1,56 +0,0 @@ -# Welcome to Graphcool! -# -# This file is the main config file for your Graphcool Service. -# It's very minimal at this point and uses default values. -# We've included a hello world function here. -# Just run `graphcool deploy` to have the first running Graphcool Service. -# -# Check out some examples: -# https://github.com/graphcool/graphcool/tree/master/examples -# -# Here are the reference docs of this definition format: -# https://docs-next.graph.cool/reference/service-definition/graphcool.yml-foatho8aip -# -# Happy Coding! - - -# In the types.graphql you define your data schema -types: ./types.graphql - - -functions: - -# added by auth0 template: (please uncomment) -# - authenticate: - handler: - code: - src: ./src/auth0/auth0Authentication.js - environment: - AUTH0_DOMAIN: wesbos.auth0.com - AUTH0_API_IDENTIFIER: https://wesbos.auth0.com/api/v2/ - type: resolver - schema: ./src/auth0/auth0Authentication.graphql - - createCharge: - handler: - code: src/createCharge.js - type: operationBefore - operation: Order.create - - -# Model/Relation permissions are used to limit the API access -# To take the burden of thinking about those while development, we -# preconfigured the wildcard ("*") permission that allows everything -# Read more here: -# https://docs-next.graph.cool/reference/auth/authorization/overview-iegoo0heez -permissions: -- operation: "*" - - -# Your root tokens used for functions to get full access to the API -# Read more here: -# https://docs-next.graph.cool/reference/auth/authentication/authentication-tokens-eip7ahqu5o -# rootTokens: -# - mytoken - diff --git a/graphcool-old/package-lock.json b/graphcool-old/package-lock.json deleted file mode 100644 index 7907621..0000000 --- a/graphcool-old/package-lock.json +++ /dev/null @@ -1,790 +0,0 @@ -{ - "name": "graphcool", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@types/body-parser": { - "version": "1.16.7", - "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.16.7.tgz", - "integrity": "sha512-Obn1/GG0sYsnlAlhhSR1hvYRGBpQT+fzSi2IlGN8emCE4iu6f6xIjaq499B1sa7N9iBLzxyOUBo5bzgJd16BvA==", - "requires": { - "@types/express": "4.0.39", - "@types/node": "8.0.47" - } - }, - "@types/express": { - "version": "4.0.39", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.0.39.tgz", - "integrity": "sha512-dBUam7jEjyuEofigUXCtublUHknRZvcRgITlGsTbFgPvnTwtQUt2NgLakbsf+PsGo/Nupqr3IXCYsOpBpofyrA==", - "requires": { - "@types/body-parser": "1.16.7", - "@types/express-serve-static-core": "4.0.55", - "@types/serve-static": "1.13.0" - } - }, - "@types/express-jwt": { - "version": "0.0.34", - "resolved": "https://registry.npmjs.org/@types/express-jwt/-/express-jwt-0.0.34.tgz", - "integrity": "sha1-/b7kxq9cCiRu8qkz9VGZc8dxfwI=", - "requires": { - "@types/express": "4.0.39", - "@types/express-unless": "0.0.32" - } - }, - "@types/express-serve-static-core": { - "version": "4.0.55", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.0.55.tgz", - "integrity": "sha512-sDFubLXpgiluVW+2txOp877cQp7FyWYB9eMJTm3oAsX4HlGqIKiPcNpJq5XDKCTOMuVbnNMALYmayaj9KlRntg==", - "requires": { - "@types/node": "8.0.47" - } - }, - "@types/express-unless": { - "version": "0.0.32", - "resolved": "https://registry.npmjs.org/@types/express-unless/-/express-unless-0.0.32.tgz", - "integrity": "sha512-6YpJyFNlDDnPnRjMOvJCoDYlSDDmG/OEEUsPk7yhNkL4G9hUYtgab6vi1CcWsGSSSM0CsvNlWTG+ywAGnvF03g==", - "requires": { - "@types/express": "4.0.39" - } - }, - "@types/mime": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.0.tgz", - "integrity": "sha512-A2TAGbTFdBw9azHbpVd+/FkdW2T6msN1uct1O9bH3vTerEHKZhTXJUQXy+hNq1B0RagfU8U+KBdqiZpxjhOUQA==" - }, - "@types/node": { - "version": "8.0.47", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.47.tgz", - "integrity": "sha512-kOwL746WVvt/9Phf6/JgX/bsGQvbrK5iUgzyfwZNcKVFcjAUVSpF9HxevLTld2SG9aywYHOILj38arDdY1r/iQ==" - }, - "@types/serve-static": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.0.tgz", - "integrity": "sha512-wvQkePwCDZoyQPGb64DTl2TEeLw54CQFXjY+tznxYYxNcBb4LG40ezoVbMDa0epwE4yogB0f42jCaH0356x5Mg==", - "requires": { - "@types/express-serve-static-core": "4.0.55", - "@types/mime": "2.0.0" - } - }, - "ajv": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.3.0.tgz", - "integrity": "sha1-RBT/dKUIecII7l/cgm4ywwNUnto=", - "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.0.0", - "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" - } - }, - "apollo-fetch": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/apollo-fetch/-/apollo-fetch-0.6.0.tgz", - "integrity": "sha1-qumyjBF680SwkeyLpNGlqgR03F0=", - "requires": { - "isomorphic-fetch": "2.2.1" - } - }, - "apollo-link": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/apollo-link/-/apollo-link-0.7.0.tgz", - "integrity": "sha512-LPwygaqW57k7D5rKEdd5xZcLL7SY7MbUkvDYXfU/+el6Iq46AXfxJICXrU6UVydngEBD1DYm0t8CT4JRk0MR7g==", - "requires": { - "apollo-utilities": "0.2.0-rc.3", - "graphql": "0.11.7", - "zen-observable-ts": "0.5.0" - } - }, - "apollo-link-http": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/apollo-link-http/-/apollo-link-http-0.7.0.tgz", - "integrity": "sha512-BCYxduD5oHfsiWz15pcjooyAsP4E6gmL1BH4z4ikwU6I++QhbIBt5zH+ezUQcOKcozNY7+ZfcA4oaRud9FbkbA==", - "requires": { - "apollo-fetch": "0.6.0", - "graphql": "0.11.7" - } - }, - "apollo-utilities": { - "version": "0.2.0-rc.3", - "resolved": "https://registry.npmjs.org/apollo-utilities/-/apollo-utilities-0.2.0-rc.3.tgz", - "integrity": "sha512-UM5ok/DUKSgh/3T302hoPqCAhqfXdvBaQKOQJb0QUuX3qu2qVKzvwFsv/C3zWYySeCJTP9EoV2LtooIJOhSL4g==" - }, - "asn1": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" - }, - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" - }, - "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" - }, - "aws4": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" - }, - "base64url": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/base64url/-/base64url-2.0.0.tgz", - "integrity": "sha1-6sFuA+oUOO/5Qj1puqNiYu0fcLs=" - }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", - "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", - "optional": true, - "requires": { - "tweetnacl": "0.14.5" - } - }, - "bluebird": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" - }, - "boom": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", - "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", - "requires": { - "hoek": "4.2.0" - } - }, - "buffer-equal-constant-time": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", - "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=" - }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" - }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" - }, - "combined-stream": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", - "requires": { - "delayed-stream": "1.0.0" - } - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" - }, - "cross-fetch": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-0.0.8.tgz", - "integrity": "sha1-Ae2U3EB98sAPGAf95wCnz6SKIFw=", - "requires": { - "node-fetch": "1.7.3", - "whatwg-fetch": "2.0.3" - } - }, - "cryptiles": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", - "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", - "requires": { - "boom": "5.2.0" - }, - "dependencies": { - "boom": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", - "requires": { - "hoek": "4.2.0" - } - } - } - }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "requires": { - "assert-plus": "1.0.0" - } - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { - "ms": "2.0.0" - } - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" - }, - "deprecated-decorator": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/deprecated-decorator/-/deprecated-decorator-0.1.6.tgz", - "integrity": "sha1-AJZjF7ehL+kvPMgx91g68ym4bDc=" - }, - "ecc-jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", - "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", - "optional": true, - "requires": { - "jsbn": "0.1.1" - } - }, - "ecdsa-sig-formatter": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.9.tgz", - "integrity": "sha1-S8kmJ07Dtau1AW5+HWCSGsJisqE=", - "requires": { - "base64url": "2.0.0", - "safe-buffer": "5.1.1" - } - }, - "encoding": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", - "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", - "requires": { - "iconv-lite": "0.4.19" - } - }, - "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" - }, - "fast-deep-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", - "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=" - }, - "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" - }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" - }, - "form-data": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", - "integrity": "sha1-b7lPvXGIUwbXPRXMSX/kzE7NRL8=", - "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" - } - }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "requires": { - "assert-plus": "1.0.0" - } - }, - "graphcool-lib": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/graphcool-lib/-/graphcool-lib-0.1.4.tgz", - "integrity": "sha512-qUmcS+nQLPR3gTOvfQbHAdwKkwBJlUIm1SNb+5lcPkh3iIPXSISHJcpt7kECNB2s75O8shKYGMXJRd3F5S2Aaw==", - "requires": { - "apollo-link": "0.7.0", - "apollo-link-http": "0.7.0", - "graphql": "0.11.7", - "graphql-request": "1.4.0", - "graphql-tools": "2.6.1", - "node-fetch": "1.7.3", - "source-map-support": "0.4.18" - } - }, - "graphql": { - "version": "0.11.7", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-0.11.7.tgz", - "integrity": "sha512-x7uDjyz8Jx+QPbpCFCMQ8lltnQa4p4vSYHx6ADe8rVYRTdsyhCJbvSty5DAsLVmU6cGakl+r8HQYolKHxk/tiw==", - "requires": { - "iterall": "1.1.3" - } - }, - "graphql-request": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/graphql-request/-/graphql-request-1.4.0.tgz", - "integrity": "sha512-lAAbaq2IbeN4sGcgQgx/OtxEZ9UimpWawIEUYAw8Dk0yNAYPwWH79/ASdGrH/5aTvYHz3U7CjgoQmaiUpLJ3qw==", - "requires": { - "cross-fetch": "0.0.8" - } - }, - "graphql-tools": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/graphql-tools/-/graphql-tools-2.6.1.tgz", - "integrity": "sha1-n20WAJUaBbGLg8UphsQu7k/Tyxs=", - "requires": { - "apollo-utilities": "0.1.1-1", - "deprecated-decorator": "0.1.6", - "uuid": "3.1.0" - }, - "dependencies": { - "apollo-utilities": { - "version": "0.1.1-1", - "resolved": "https://registry.npmjs.org/apollo-utilities/-/apollo-utilities-0.1.1-1.tgz", - "integrity": "sha512-1254/E4u7B5niFoR7h3RF+Bxv+KjAe6StEHUXABeDOIcVHkjjLHx++ZKDdZeTjwDow4tMc5fkhwpZ5vzxezyxQ==" - } - } - }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" - }, - "har-validator": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", - "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", - "requires": { - "ajv": "5.3.0", - "har-schema": "2.0.0" - } - }, - "hawk": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", - "requires": { - "boom": "4.3.1", - "cryptiles": "3.1.2", - "hoek": "4.2.0", - "sntp": "2.1.0" - } - }, - "hoek": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz", - "integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ==" - }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "requires": { - "assert-plus": "1.0.0", - "jsprim": "1.4.1", - "sshpk": "1.13.1" - } - }, - "iconv-lite": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", - "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" - }, - "isomorphic-fetch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", - "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", - "requires": { - "node-fetch": "1.7.3", - "whatwg-fetch": "2.0.3" - } - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" - }, - "iterall": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/iterall/-/iterall-1.1.3.tgz", - "integrity": "sha512-Cu/kb+4HiNSejAPhSaN1VukdNTTi/r4/e+yykqjlG/IW+1gZH5b4+Bq3whDX4tvbYugta3r8KTMUiqT3fIGxuQ==" - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "optional": true - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" - }, - "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" - }, - "jsonwebtoken": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.1.0.tgz", - "integrity": "sha1-xjl80uX9WD1lwAeoPce7eOaYK4M=", - "requires": { - "jws": "3.1.4", - "lodash.includes": "4.3.0", - "lodash.isboolean": "3.0.3", - "lodash.isinteger": "4.0.4", - "lodash.isnumber": "3.0.3", - "lodash.isplainobject": "4.0.6", - "lodash.isstring": "4.0.1", - "lodash.once": "4.1.1", - "ms": "2.0.0", - "xtend": "4.0.1" - } - }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - } - }, - "jwa": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.1.5.tgz", - "integrity": "sha1-oFUs4CIHQs1S4VN3SjKQXDDnVuU=", - "requires": { - "base64url": "2.0.0", - "buffer-equal-constant-time": "1.0.1", - "ecdsa-sig-formatter": "1.0.9", - "safe-buffer": "5.1.1" - } - }, - "jwks-rsa": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/jwks-rsa/-/jwks-rsa-1.2.1.tgz", - "integrity": "sha512-xg+fw7FOV4eGdDIEMqQJvPLmFv85h4uN+j/GKwJZAxlCrDQpM8ov1F709xKGEp/dG3l4TUxoSOeN6YK7+KpinQ==", - "requires": { - "@types/express-jwt": "0.0.34", - "debug": "2.6.9", - "limiter": "1.1.2", - "lru-memoizer": "1.11.1", - "ms": "2.0.0", - "request": "2.83.0" - } - }, - "jws": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/jws/-/jws-3.1.4.tgz", - "integrity": "sha1-+ei5M46KhHJ31kRLFGT2GIDgUKI=", - "requires": { - "base64url": "2.0.0", - "jwa": "1.1.5", - "safe-buffer": "5.1.1" - } - }, - "limiter": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/limiter/-/limiter-1.1.2.tgz", - "integrity": "sha512-JIKZ0xb6fZZYa3deZ0BgXCgX6HgV8Nx3mFGeFHmFWW8Fb2c08e0CyE+G3nalpD0xGvGssjGb1UdFr+PprxZEbw==" - }, - "lock": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/lock/-/lock-0.1.4.tgz", - "integrity": "sha1-/sfervF+fDoKVeHaBCgD4l2RdF0=" - }, - "lodash": { - "version": "4.5.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.5.1.tgz", - "integrity": "sha1-gOigdMpfOJOmscELKmNkktcQwxY=" - }, - "lodash.includes": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", - "integrity": "sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8=" - }, - "lodash.isboolean": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", - "integrity": "sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY=" - }, - "lodash.isinteger": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", - "integrity": "sha1-YZwK89A/iwTDH1iChAt3sRzWg0M=" - }, - "lodash.isnumber": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", - "integrity": "sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w=" - }, - "lodash.isplainobject": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" - }, - "lodash.isstring": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=" - }, - "lodash.once": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", - "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=" - }, - "lru-cache": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.0.2.tgz", - "integrity": "sha1-HRdnnAac2l0ECZGgnbwsDbN35V4=", - "requires": { - "pseudomap": "1.0.2", - "yallist": "2.1.2" - } - }, - "lru-memoizer": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/lru-memoizer/-/lru-memoizer-1.11.1.tgz", - "integrity": "sha1-BpP2EAWTkUwC4ZK/m42TiEy/UNM=", - "requires": { - "lock": "0.1.4", - "lodash": "4.5.1", - "lru-cache": "4.0.2", - "very-fast-args": "1.1.0" - } - }, - "mime-db": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", - "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" - }, - "mime-types": { - "version": "2.1.17", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", - "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", - "requires": { - "mime-db": "1.30.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "requires": { - "encoding": "0.1.12", - "is-stream": "1.1.0" - } - }, - "oauth-sign": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" - }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" - }, - "pseudomap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" - }, - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" - }, - "qs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" - }, - "request": { - "version": "2.83.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz", - "integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==", - "requires": { - "aws-sign2": "0.7.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.3.1", - "har-validator": "5.0.3", - "hawk": "6.0.2", - "http-signature": "1.2.0", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", - "oauth-sign": "0.8.2", - "performance-now": "2.1.0", - "qs": "6.5.1", - "safe-buffer": "5.1.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.3", - "tunnel-agent": "0.6.0", - "uuid": "3.1.0" - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" - }, - "sntp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", - "requires": { - "hoek": "4.2.0" - } - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=" - }, - "source-map-support": { - "version": "0.4.18", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", - "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", - "requires": { - "source-map": "0.5.7" - } - }, - "sshpk": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", - "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", - "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" - } - }, - "stringstream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=" - }, - "stripe": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/stripe/-/stripe-5.2.0.tgz", - "integrity": "sha512-Mjw4CEMa3bONxIkaaxnNd3HcMMWgw2ZaOj3NW1vqnJ9PCOmVuXWWHLiZ3HD4vz3Vqh8VjqL2bIW9C9KB39sA6w==", - "requires": { - "bluebird": "3.5.1", - "lodash.isplainobject": "4.0.6", - "qs": "6.5.1", - "safe-buffer": "5.1.1" - } - }, - "tough-cookie": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", - "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", - "requires": { - "punycode": "1.4.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "requires": { - "safe-buffer": "5.1.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "optional": true - }, - "uuid": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" - }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "requires": { - "assert-plus": "1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "1.3.0" - } - }, - "very-fast-args": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/very-fast-args/-/very-fast-args-1.1.0.tgz", - "integrity": "sha1-4W0dH6+KbllqJGQh/ZCneWPQs5Y=" - }, - "whatwg-fetch": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz", - "integrity": "sha1-nITsLc9oGH/wC8ZOEnS0QhduHIQ=" - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" - }, - "yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" - }, - "zen-observable-ts": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-0.5.0.tgz", - "integrity": "sha512-8soRu9VE2HYkAAKcDegToWzu8snITcZjujnE4SXc+7IczbHXRCFkd4Cj4DgYq88nU6SwTU5lkea7KBGNa/CaFw==" - } - } -} diff --git a/graphcool-old/package.json b/graphcool-old/package.json deleted file mode 100644 index bc443d2..0000000 --- a/graphcool-old/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "graphcool", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "isomorphic-fetch": "^2.2.1", - "stripe": "^5.2.0", - "graphcool-lib": "^0.1.0", - "jsonwebtoken": "^8.1.0", - "jwks-rsa": "^1.2.1" - } -} diff --git a/graphcool-old/project.graphcool b/graphcool-old/project.graphcool deleted file mode 100644 index 193c9eb..0000000 --- a/graphcool-old/project.graphcool +++ /dev/null @@ -1,52 +0,0 @@ -# project: cj5xz8szs28930145gct82bdj -# version: 69 - -type File implements Node { - contentType: String! - createdAt: DateTime! - id: ID! @isUnique - item: Item @relation(name: "Photo") - name: String! - secret: String! @isUnique - size: Int! - updatedAt: DateTime! - url: String! @isUnique -} - -type Item implements Node { - createdAt: DateTime! - description: String! - fullPrice: Int - id: ID! @isUnique - image: File @relation(name: "Photo") - order: Order @relation(name: "OrderOnItem") - price: Int - title: String! - updatedAt: DateTime! - user: User @relation(name: "CartItems") -} - -type Order implements Node { - amount: Int - charge: String - createdAt: DateTime! - id: ID! @isUnique - item: Item @relation(name: "OrderOnItem") - token: String - updatedAt: DateTime! - user: User @relation(name: "OrderOnUser") -} - -type User implements Node { - createdAt: DateTime! - email: String @isUnique - id: ID! @isUnique - isVerified: Boolean! @defaultValue(value: false) - orders: [Order!]! @relation(name: "OrderOnUser") - password: String - secret: String @isUnique - updatedAt: DateTime! - auth0UserId: String @isUnique - name: String! - cart: [Item!]! @relation(name: "CartItems") -}
\ No newline at end of file diff --git a/graphcool-old/src/auth0/auth0Authentication.graphql b/graphcool-old/src/auth0/auth0Authentication.graphql deleted file mode 100644 index 823a71b..0000000 --- a/graphcool-old/src/auth0/auth0Authentication.graphql +++ /dev/null @@ -1,8 +0,0 @@ -type AuthenticateUserPayload { - id: String! - token: String! -} - -extend type Mutation { - authenticateUser(accessToken: String!): AuthenticateUserPayload -} diff --git a/graphcool-old/src/auth0/auth0Authentication.js b/graphcool-old/src/auth0/auth0Authentication.js deleted file mode 100644 index 82165d1..0000000 --- a/graphcool-old/src/auth0/auth0Authentication.js +++ /dev/null @@ -1,100 +0,0 @@ -const isomorphicFetch = require('isomorphic-fetch'); -const jwt = require('jsonwebtoken'); -const jwkRsa = require('jwks-rsa'); -const fromEvent = require('graphcool-lib').fromEvent; - -// Validates the request JWT token -const verifyToken = token => - new Promise(resolve => { - // Decode the JWT Token - const decoded = jwt.decode(token, { complete: true }); - if (!decoded || !decoded.header || !decoded.header.kid) { - throw new Error('Unable to retrieve key identifier from token'); - } - if (decoded.header.alg !== 'RS256') { - throw new Error(`Wrong signature algorithm, expected RS256, got ${decoded.header.alg}`); - } - const jkwsClient = jwkRsa({ - cache: true, - jwksUri: `https://${process.env.AUTH0_DOMAIN}/.well-known/jwks.json`, - }); - // Retrieve the JKWS's signing key using the decode token's key identifier (kid) - jkwsClient.getSigningKey(decoded.header.kid, (err, key) => { - if (err) throw new Error(err); - const signingKey = key.publicKey || key.rsaPublicKey; - // If the JWT Token was valid, verify its validity against the JKWS's signing key - jwt.verify( - token, - signingKey, - { - algorithms: ['RS256'], - audience: process.env.AUTH0_API_IDENTIFIER, - ignoreExpiration: false, - issuer: `https://${process.env.AUTH0_DOMAIN}/`, - }, - (err, decoded) => { - if (err) throw new Error(err); - return resolve(decoded); - } - ); - }); - }); - -// Retrieves the Graphcool user record using the Auth0 user id -const getGraphcoolUser = (auth0UserId, api) => - api - .request( - ` - query getUser($auth0UserId: String!){ - User(auth0UserId: $auth0UserId){ - id - } - } - `, - { auth0UserId } - ) - .then(queryResult => queryResult.User); - -// Creates a new User record. -const createGraphCoolUser = ({ sub }, api) => - api - .request( - ` - mutation createUser($auth0UserId: String!) { - createUser( - auth0UserId: $auth0UserId - ){ - id - } - } - `, - { auth0UserId: sub } - ) - .then(queryResult => queryResult.createUser); - -export default async event => { - try { - if (!process.env.AUTH0_DOMAIN || !process.env.AUTH0_API_IDENTIFIER) { - throw new Error('Missing AUTH0_DOMAIN or AUTH0_API_IDENTIFIER environment variable'); - } - const { accessToken } = event.data; - - const decodedToken = await verifyToken(accessToken); - const graphcool = fromEvent(event); - const api = graphcool.api('simple/v1'); - - let graphCoolUser = null; - - graphCoolUser = await getGraphcoolUser(decodedToken.sub, api); - // If the user doesn't exist. a new record is created. - if (graphCoolUser === null) { - graphCoolUser = await createGraphCoolUser(decodedToken, api); - } - const token = await graphcool.generateAuthToken(graphCoolUser.id, 'User'); - - return { data: { id: graphCoolUser.id, token } }; - } catch (err) { - console.log(err); - return { error: 'An unexpected error occured' }; - } -}; diff --git a/graphcool-old/src/createCharge.js b/graphcool-old/src/createCharge.js deleted file mode 100644 index ccf9c11..0000000 --- a/graphcool-old/src/createCharge.js +++ /dev/null @@ -1,52 +0,0 @@ -const stripe = require('stripe')('sk_ycLkGc2cAaBDSCKkHiKVBeT71CMxd'); - -const endpoint = 'https://api.graph.cool/simple/v1/cj99zm6ye06sb01325ic751ww'; - -require('isomorphic-fetch'); - -const getPrice = itemId => { - const query = ` - query SingleItem { - Item(id: "${itemId}") { - price - } - } - `; - - return fetch(endpoint, { - method: 'post', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ query }), - }); -}; - -const createStripeCharge = (token, amount) => - stripe.charges.create({ - amount, - currency: 'usd', - description: `a test charge`, - source: token, - }); - -module.exports = function(event) { - return new Promise((resolve, reject) => { - // first find out the price of the item - getPrice(event.data.itemId) - .then(res => res.json()) - .then(res => { - console.log(`Back with the price ${res.data.Item.price}!`); - return createStripeCharge(event.data.token, res.data.Item.price); - }) - .then(res => { - console.log(`Back! charge ${res.id} for the amount ${res.amount}`); - event.data.charge = res.id; - event.data.amount = res.amount; - resolve(event); - }) - .catch(err => { - reject(err); - }); - }); -}; diff --git a/graphcool-old/src/createCharge.test.js b/graphcool-old/src/createCharge.test.js deleted file mode 100644 index 65dde47..0000000 --- a/graphcool-old/src/createCharge.test.js +++ /dev/null @@ -1,23 +0,0 @@ -const takeMoney = require('./createCharge'); - -const event = { - "data": { - "user": "cj6ntm8qic3260140vkuzif9d", - "token": "tok_visa", - }, - "context": { - "headers": {} - } -} - - -describe('Take Money', () => { - - test('A charge has come back', async () => { - const res = await takeMoney(event); - console.log(res); - expect(res.data.amount).toBeGreaterThanOrEqual(0); - }); - -}); - diff --git a/graphcool-old/src/getPrice.js b/graphcool-old/src/getPrice.js deleted file mode 100644 index 7808a85..0000000 --- a/graphcool-old/src/getPrice.js +++ /dev/null @@ -1,26 +0,0 @@ -require('isomorphic-fetch') - -const query = ` -query SingleItem { - Item(id: "cj64bs7vuuqgu0116ul5cm223") { - price - } -} -`; - -function getItem(id) { - return fetch('https://api.graph.cool/simple/v1/cj5xz8szs28930145gct82bdj', { - method: 'post', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ query }), - }) -} - - -module.exports = function(event) { - getItem().then(x => x.json()).then(res => { - console.log(res.data.Item.price); - }).catch(console.log) -} diff --git a/graphcool-old/src/hello.graphql b/graphcool-old/src/hello.graphql deleted file mode 100644 index d43c729..0000000 --- a/graphcool-old/src/hello.graphql +++ /dev/null @@ -1,7 +0,0 @@ -type HelloPayload { - message: String! -} - -extend type Query { - hello(name: String): HelloPayload -} diff --git a/graphcool-old/src/hello.js b/graphcool-old/src/hello.js deleted file mode 100644 index 0e3e7ba..0000000 --- a/graphcool-old/src/hello.js +++ /dev/null @@ -1,11 +0,0 @@ -export default async event => { - // you can use ES7 with async/await and even TypeScript in your functions :) - - await new Promise(r => setTimeout(r, 50)) - - return { - data: { - message: `Hello ${event.data.name || 'World'}` - } - } -}
\ No newline at end of file diff --git a/graphcool-old/src/index.js b/graphcool-old/src/index.js deleted file mode 100644 index ee451f6..0000000 --- a/graphcool-old/src/index.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports = () => 'Welcome to Micro' -exports.what = () => 'What' diff --git a/graphcool-old/types.graphql b/graphcool-old/types.graphql deleted file mode 100644 index dcdd690..0000000 --- a/graphcool-old/types.graphql +++ /dev/null @@ -1,56 +0,0 @@ -# The following types define the data model of the example service -# based on which the GraphQL API is generated - -type File @model { - contentType: String! - createdAt: DateTime! - id: ID! @isUnique - item: Item @relation(name: "Photo") - name: String! - secret: String! @isUnique - size: Int! - updatedAt: DateTime! - url: String! @isUnique -} - -type Item @model { - createdAt: DateTime! - description: String! - fullPrice: Int - id: ID! @isUnique - image: File @relation(name: "Photo") - order: Order @relation(name: "OrderOnItem") - price: Int - title: String! - updatedAt: DateTime! - user: User @relation(name: "CartItems") -} - -type Order @model { - amount: Int - charge: String - createdAt: DateTime! - id: ID! @isUnique - item: Item @relation(name: "OrderOnItem") - token: String - updatedAt: DateTime! - user: User @relation(name: "OrderOnUser") -} - -type User @model { - createdAt: DateTime! - email: String @isUnique - id: ID! @isUnique - isVerified: Boolean! @defaultValue(value: false) - orders: [Order!]! @relation(name: "OrderOnUser") - password: String - secret: String @isUnique - updatedAt: DateTime! - auth0UserId: String @isUnique - name: String! - cart: [Item!]! @relation(name: "CartItems") - level: Int -} - - - diff --git a/graphcool/.graphcoolrc b/graphcool/.graphcoolrc deleted file mode 100644 index a83bc41..0000000 --- a/graphcool/.graphcoolrc +++ /dev/null @@ -1,4 +0,0 @@ -targets: - prod: shared-eu-west-1/cjctbkp4o02fh0105aff50ccn - default: local - local: local/cjctdwrq1000e0149tlqfs0c7 diff --git a/graphcool/graphcool.yml b/graphcool/graphcool.yml deleted file mode 100644 index 6434b57..0000000 --- a/graphcool/graphcool.yml +++ /dev/null @@ -1,44 +0,0 @@ -# Welcome to Graphcool! -# -# This file is the main config file for your Graphcool Service. -# It's very minimal at this point and uses default values. -# We've included a hello world function here. -# Just run `graphcool deploy` to have the first running Graphcool Service. -# -# Check out some examples: -# https://github.com/graphcool/graphcool/tree/master/examples -# -# Here are the reference docs of this definition format: -# https://docs-next.graph.cool/reference/service-definition/graphcool.yml-foatho8aip -# -# Happy Coding! - - -# In the types.graphql you define your data schema -types: ./types.graphql - - -functions: - - createCharge: - handler: - code: src/createCharge.js - type: operationBefore - operation: Order.create - - -# Model/Relation permissions are used to limit the API access -# To take the burden of thinking about those while development, we -# preconfigured the wildcard ("*") permission that allows everything -# Read more here: -# https://docs-next.graph.cool/reference/auth/authorization/overview-iegoo0heez -permissions: -- operation: "*" - - -# Your root tokens used for functions to get full access to the API -# Read more here: -# https://docs-next.graph.cool/reference/auth/authentication/authentication-tokens-eip7ahqu5o -# rootTokens: -# - mytoken - diff --git a/graphcool/package-lock.json b/graphcool/package-lock.json deleted file mode 100644 index c952a86..0000000 --- a/graphcool/package-lock.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "graphcool", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "bluebird": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" - }, - "lodash.isplainobject": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" - }, - "qs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" - }, - "stripe": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/stripe/-/stripe-5.4.0.tgz", - "integrity": "sha512-VCDFp4oQu1uOcOLHIwRIznH8ikLJcpDsHahWN48V/QuV6y2Bm281cq5wnkjqv+LPdUpqXVp9pjlb+SfN6dnyZg==", - "requires": { - "bluebird": "3.5.1", - "lodash.isplainobject": "4.0.6", - "qs": "6.5.1", - "safe-buffer": "5.1.1" - } - } - } -} diff --git a/graphcool/package.json b/graphcool/package.json deleted file mode 100644 index 6fccf4b..0000000 --- a/graphcool/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "graphcool", - "version": "1.0.0", - "description": "My Graphcool Service", - "dependencies": { - "stripe": "^5.4.0" - } -} diff --git a/graphcool/src/createCharge.js b/graphcool/src/createCharge.js deleted file mode 100644 index ccf9c11..0000000 --- a/graphcool/src/createCharge.js +++ /dev/null @@ -1,52 +0,0 @@ -const stripe = require('stripe')('sk_ycLkGc2cAaBDSCKkHiKVBeT71CMxd'); - -const endpoint = 'https://api.graph.cool/simple/v1/cj99zm6ye06sb01325ic751ww'; - -require('isomorphic-fetch'); - -const getPrice = itemId => { - const query = ` - query SingleItem { - Item(id: "${itemId}") { - price - } - } - `; - - return fetch(endpoint, { - method: 'post', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ query }), - }); -}; - -const createStripeCharge = (token, amount) => - stripe.charges.create({ - amount, - currency: 'usd', - description: `a test charge`, - source: token, - }); - -module.exports = function(event) { - return new Promise((resolve, reject) => { - // first find out the price of the item - getPrice(event.data.itemId) - .then(res => res.json()) - .then(res => { - console.log(`Back with the price ${res.data.Item.price}!`); - return createStripeCharge(event.data.token, res.data.Item.price); - }) - .then(res => { - console.log(`Back! charge ${res.id} for the amount ${res.amount}`); - event.data.charge = res.id; - event.data.amount = res.amount; - resolve(event); - }) - .catch(err => { - reject(err); - }); - }); -}; diff --git a/graphcool/src/createCharge.test.js b/graphcool/src/createCharge.test.js deleted file mode 100644 index 65dde47..0000000 --- a/graphcool/src/createCharge.test.js +++ /dev/null @@ -1,23 +0,0 @@ -const takeMoney = require('./createCharge'); - -const event = { - "data": { - "user": "cj6ntm8qic3260140vkuzif9d", - "token": "tok_visa", - }, - "context": { - "headers": {} - } -} - - -describe('Take Money', () => { - - test('A charge has come back', async () => { - const res = await takeMoney(event); - console.log(res); - expect(res.data.amount).toBeGreaterThanOrEqual(0); - }); - -}); - diff --git a/graphcool/src/getPrice.js b/graphcool/src/getPrice.js deleted file mode 100644 index 7808a85..0000000 --- a/graphcool/src/getPrice.js +++ /dev/null @@ -1,26 +0,0 @@ -require('isomorphic-fetch') - -const query = ` -query SingleItem { - Item(id: "cj64bs7vuuqgu0116ul5cm223") { - price - } -} -`; - -function getItem(id) { - return fetch('https://api.graph.cool/simple/v1/cj5xz8szs28930145gct82bdj', { - method: 'post', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ query }), - }) -} - - -module.exports = function(event) { - getItem().then(x => x.json()).then(res => { - console.log(res.data.Item.price); - }).catch(console.log) -} diff --git a/graphcool/src/hello.graphql b/graphcool/src/hello.graphql deleted file mode 100644 index d43c729..0000000 --- a/graphcool/src/hello.graphql +++ /dev/null @@ -1,7 +0,0 @@ -type HelloPayload { - message: String! -} - -extend type Query { - hello(name: String): HelloPayload -} diff --git a/graphcool/src/hello.js b/graphcool/src/hello.js deleted file mode 100644 index 0e3e7ba..0000000 --- a/graphcool/src/hello.js +++ /dev/null @@ -1,11 +0,0 @@ -export default async event => { - // you can use ES7 with async/await and even TypeScript in your functions :) - - await new Promise(r => setTimeout(r, 50)) - - return { - data: { - message: `Hello ${event.data.name || 'World'}` - } - } -}
\ No newline at end of file diff --git a/graphcool/src/index.js b/graphcool/src/index.js deleted file mode 100644 index ee451f6..0000000 --- a/graphcool/src/index.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports = () => 'Welcome to Micro' -exports.what = () => 'What' diff --git a/graphcool/types.graphql b/graphcool/types.graphql deleted file mode 100644 index 44fea35..0000000 --- a/graphcool/types.graphql +++ /dev/null @@ -1,53 +0,0 @@ -# The following types define the data model of the example service -# based on which the GraphQL API is generated - -type File @model { - contentType: String! - createdAt: DateTime! - id: ID! @isUnique - item: Item @relation(name: "Photo") - name: String! - secret: String! @isUnique - size: Int! - updatedAt: DateTime! - url: String! @isUnique -} - -type Item @model { - createdAt: DateTime! - description: String! - fullPrice: Int - id: ID! @isUnique - image: File @relation(name: "Photo") - order: Order @relation(name: "OrderOnItem") - price: Int - title: String! - updatedAt: DateTime! - user: User @relation(name: "CartItems") -} - -type Order @model { - amount: Int - charge: String - createdAt: DateTime! - id: ID! @isUnique - item: Item @relation(name: "OrderOnItem") - token: String - updatedAt: DateTime! - user: User @relation(name: "OrderOnUser") -} - -type User @model { - createdAt: DateTime! - email: String @isUnique - id: ID! @isUnique - isVerified: Boolean! @defaultValue(value: false) - orders: [Order!]! @relation(name: "OrderOnUser") - password: String - secret: String @isUnique - updatedAt: DateTime! - auth0UserId: String @isUnique - name: String! - cart: [Item!]! @relation(name: "CartItems") - level: Int -} |
