Wipe slate clean

This commit is contained in:
Kurt Hutten
2020-11-01 18:05:19 +11:00
parent e11593a794
commit 55f9dfd6de
74 changed files with 2 additions and 2169 deletions

View File

@@ -1,29 +0,0 @@
export const schema = gql`
type Contact {
id: Int!
name: String!
email: String!
message: String!
createdAt: DateTime!
}
type Query {
contacts: [Contact!]!
}
input CreateContactInput {
name: String!
email: String!
message: String!
}
input UpdateContactInput {
name: String
email: String
message: String
}
type Mutation {
createContact(input: CreateContactInput!): Contact
}
`

View File

@@ -1,35 +0,0 @@
export const schema = gql`
type Part {
id: Int!
title: String!
description: String!
code: String!
mainImage: String!
createdAt: DateTime!
}
type Query {
parts: [Part!]!
part(id: Int!): Part
}
input CreatePartInput {
title: String!
description: String!
code: String
mainImage: String
}
input UpdatePartInput {
title: String
description: String
code: String
mainImage: String
}
type Mutation {
createPart(input: CreatePartInput!): Part!
updatePart(id: Int!, input: UpdatePartInput!): Part!
deletePart(id: Int!): Part!
}
`

View File

@@ -1,29 +0,0 @@
export const schema = gql`
type Post {
id: Int!
title: String!
body: String!
createdAt: DateTime!
}
type Query {
posts: [Post!]!
post(id: Int!): Post
}
input CreatePostInput {
title: String!
body: String!
}
input UpdatePostInput {
title: String
body: String
}
type Mutation {
createPost(input: CreatePostInput!): Post!
updatePost(id: Int!, input: UpdatePostInput!): Post!
deletePost(id: Int!): Post!
}
`

View File

@@ -1,35 +0,0 @@
export const schema = gql`
type User {
id: Int!
email: String!
createdAt: DateTime!
updatedAt: DateTime!
image: String
bio: String
}
type Query {
users: [User!]!
user(id: Int!): User
}
input CreateUserInput {
email: String!
# issuer: String!
image: String
bio: String
}
input UpdateUserInput {
email: String
# issuer: String
image: String
bio: String
}
type Mutation {
createUser(input: CreateUserInput!): User!
updateUser(id: Int!, input: UpdateUserInput!): User!
deleteUser(id: Int!): User!
}
`

View File

@@ -1,24 +0,0 @@
import { UserInputError } from '@redwoodjs/api'
import { db } from 'src/lib/db'
const validate = (input) => {
if (input.email && !input.email.match(/[^@]+@[^.]+\..+/)) {
throw new UserInputError("Can't create new contact", {
messages: {
email: ['is not formatted like an email address'],
},
})
}
}
export const contacts = () => {
return db.contact.findMany()
}
export const createContact = ({ input }) => {
validate(input)
return db.contact.create({ data: input })
}

View File

@@ -1,9 +0,0 @@
/*
import { contacts } from './contacts'
*/
describe('contacts', () => {
it('returns true', () => {
expect(true).toBe(true)
})
})

View File

@@ -1,30 +0,0 @@
import { db } from 'src/lib/db'
export const parts = () => {
return db.part.findMany()
}
export const part = ({ id }) => {
return db.part.findOne({
where: { id },
})
}
export const createPart = ({ input }) => {
return db.part.create({
data: input,
})
}
export const updatePart = ({ id, input }) => {
return db.part.update({
data: input,
where: { id },
})
}
export const deletePart = ({ id }) => {
return db.part.delete({
where: { id },
})
}

View File

@@ -1,9 +0,0 @@
/*
import { parts } from './parts'
*/
describe('parts', () => {
it('returns true', () => {
expect(true).toBe(true)
})
})

View File

@@ -1,34 +0,0 @@
import { db } from 'src/lib/db'
import { requireAuth } from 'src/lib/auth'
export const posts = () => {
return db.post.findMany()
}
export const post = ({ id }) => {
return db.post.findOne({
where: { id },
})
}
export const createPost = ({ input }) => {
requireAuth()
return db.post.create({
data: input,
})
}
export const updatePost = ({ id, input }) => {
requireAuth()
return db.post.update({
data: input,
where: { id },
})
}
export const deletePost = ({ id }) => {
requireAuth()
return db.post.delete({
where: { id },
})
}

View File

@@ -1,9 +0,0 @@
/*
import { posts } from './posts'
*/
describe('posts', () => {
it('returns true', () => {
expect(true).toBe(true)
})
})

View File

@@ -1,40 +0,0 @@
import { db } from 'src/lib/db'
import { requireAuth } from 'src/lib/auth'
export const users = () => {
requireAuth({ role: 'admin' })
return db.user.findMany()
}
export const user = ({ id }) => {
requireAuth()
return db.user.findOne({
where: { id },
})
}
export const createUser = ({ input }) => {
requireAuth({ role: 'admin' })
return createUserInsecure({input})
}
export const createUserInsecure = ({ input }) => {
return db.user.create({
data: input,
})
}
export const updateUser = ({ id, input }) => {
requireAuth()
return db.user.update({
data: input,
where: { id },
})
}
export const deleteUser = ({ id }) => {
requireAuth({ role: 'admin' })
return db.user.delete({
where: { id },
})
}

View File

@@ -1,9 +0,0 @@
/*
import { users } from './users'
*/
describe('users', () => {
it('returns true', () => {
expect(true).toBe(true)
})
})