Pre-deployment

This commit is contained in:
Rob Cameron
2020-10-07 14:41:40 -07:00
parent db42525fd9
commit 35456b0a4d
56 changed files with 1787 additions and 7 deletions

View File

@@ -0,0 +1,21 @@
import { db } from 'src/lib/db'
import { UserInputError } from '@redwoodjs/api'
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

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

View File

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

View File

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