Skip to content

Commit

Permalink
fix: types, db import
Browse files Browse the repository at this point in the history
  • Loading branch information
mplewis committed Nov 21, 2024
1 parent 08e111f commit ef25ccc
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 17 deletions.
1 change: 1 addition & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- [ ] "Serious mode" for LoadingBuddy for e.g. unsubscribe requests
- [ ] Notification when target email is denylisted on record creation
- [ ] Replace shared API lib dir with Yarn "shared package" workspace
- [ ] Add advanced crash logging
- [x] Resend confirmation if an RSVP enters an existing email
- [x] Captcha
- [x] Hold RSVP locally with cookie
Expand Down
2 changes: 1 addition & 1 deletion api/src/functions/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import directives from 'src/directives/**/*.{js,ts}'
import sdls from 'src/graphql/**/*.sdl.{js,ts}'
import services from 'src/services/**/*.{js,ts}'

import { db } from 'src/lib/backend/db'
import { logger } from 'src/lib/backend/logger'
import { wrap } from 'src/lib/backend/sentry'
import { db } from 'src/lib/db'

const baseHandler = createGraphQLHandler({
loggerConfig: { logger, options: {} },
Expand Down
2 changes: 1 addition & 1 deletion api/src/lib/backend/email/send.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { InMemoryMailHandler } from '@redwoodjs/mailer-handler-in-memory'

import { db } from '../db'
import { db } from '../../db'
import { mailer } from '../mailer'

import { sendEmail } from './send'
Expand Down
2 changes: 1 addition & 1 deletion api/src/lib/backend/email/send.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MAIL_SENDER } from 'src/api.config'
import { mailer } from 'src/lib/backend/mailer'

import { db } from '../db'
import { db } from '../../db'
import { logger } from '../logger'

import { Plain } from './plain'
Expand Down
2 changes: 1 addition & 1 deletion api/src/lib/backend/schedule/reminder.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { db } from '../db'
import { db } from '../../db'

import { sendOutstandingReminders } from './reminder'

Expand Down
2 changes: 1 addition & 1 deletion api/src/lib/backend/schedule/reminder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { db } from '../db'
import { db } from '../../db'
import { sendReminder } from '../email/template/reminder'
import { logger } from '../logger'

Expand Down
3 changes: 2 additions & 1 deletion api/src/lib/backend/tidy.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { randomString, randomInteger } from 'remeda'
import { Event, Response } from 'types/graphql'

import { db } from './db'
import { db } from '../db'

import { tidyUnconfirmedEvents, tidyUnconfirmedResponses } from './tidy'

function buildEvent(overrides: Partial<Event> = {}): Omit<Event, 'responses'> {
Expand Down
3 changes: 2 additions & 1 deletion api/src/lib/backend/tidy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dayjs from 'src/lib/shared/dayjs'

import { db } from './db'
import { db } from '../db'

import { logger } from './logger'

const UNCONFIRMED_EXPIRY = dayjs.duration(24, 'hours')
Expand Down
2 changes: 1 addition & 1 deletion api/src/lib/backend/db.ts → api/src/lib/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PrismaClient } from '@prisma/client'

import { emitLogLevels, handlePrismaLogging } from '@redwoodjs/api/logger'

import { logger } from './logger'
import { logger } from './backend/logger'

const prismaClient = new PrismaClient({
log: emitLogLevels(['info', 'warn', 'error']),
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/events/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import type {
import { RedwoodError, validate } from '@redwoodjs/api'

import { validateCaptcha } from 'src/lib/backend/captcha'
import { db } from 'src/lib/backend/db'
import { sendEventDetails } from 'src/lib/backend/email/template/event'
import {
notifyEventCreated,
notifyEventUpdated,
} from 'src/lib/backend/notify/event'
import { summarize } from 'src/lib/backend/response'
import { generateToken, alphaLower } from 'src/lib/backend/token'
import { db } from 'src/lib/db'
import dayjs from 'src/lib/shared/dayjs'
import { checkVisibility } from 'src/lib/shared/visibility'

Expand Down
2 changes: 1 addition & 1 deletion api/src/services/ignoredEmails/ignoredEmails.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { db } from 'src/lib/backend/db'
import { sign } from 'src/lib/backend/sign'
import { db } from 'src/lib/db'

import {
createIgnoredEmail,
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/ignoredEmails/ignoredEmails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { QueryResolvers, MutationResolvers } from 'types/graphql'

import { RedwoodError } from '@redwoodjs/api'

import { db } from 'src/lib/backend/db'
import { verify } from 'src/lib/backend/sign'
import { db } from 'src/lib/db'

const ERROR_MSG = 'Could not validate your request'

Expand Down
2 changes: 1 addition & 1 deletion api/src/services/responses/responses.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import duration from 'dayjs/plugin/duration'

import { db } from 'src/lib/backend/db'
import { db } from 'src/lib/db'
import dayjs from 'src/lib/shared/dayjs'

import {
Expand Down
4 changes: 3 additions & 1 deletion api/src/services/responses/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {
import { RedwoodError } from '@redwoodjs/api'

import { validateCaptcha } from 'src/lib/backend/captcha'
import { db } from 'src/lib/backend/db'
import {
// sendNewResponseReceived,
sendResponseConfirmation,
Expand All @@ -19,6 +18,7 @@ import {
notifyResponseDeleted,
} from 'src/lib/backend/notify/response'
import { generateToken } from 'src/lib/backend/token'
import { db } from 'src/lib/db'
import dayjs from 'src/lib/shared/dayjs'
import { reminderDurations } from 'src/lib/shared/reminder'

Expand Down Expand Up @@ -59,6 +59,8 @@ export const responseByEditToken: QueryResolvers['responseByEditToken'] =
include: { event: true, reminders: true },
})

if (!resp) throw new RedwoodError("Sorry, we couldn't find that RSVP.")

if (!resp.confirmed) {
const updated = await db.response.update({
where: { editToken },
Expand Down
3 changes: 2 additions & 1 deletion scripts/seed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Prisma } from '@prisma/client'
import { db } from 'api/src/lib/db'

import { db } from '../api/src/lib/backend/db'

export default async () => {
try {
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/PageHead/PageHead.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Metadata } from '@redwoodjs/web'

import { SITE_URL } from 'src/lib/shared/shared.config'
import { SITE_URL } from 'src/apiLibShared/shared.config'

import Typ from '../Typ/Typ'

Expand Down
7 changes: 5 additions & 2 deletions web/src/components/ResponseForm/ResponseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ const ResponseForm = (props: Props) => {
const { formState, getValues } = formMethods

const { email } = getValues()
const forbidResubmit =
email === error?.cause?.extensions?.['forbidResubmitForEmail']
const forbidResubmit = (() => {
if (!email) return false
return email === error?.cause?.extensions?.['forbidResubmitForEmail']
})()
console.log({ email, error, forbidResubmit })

const [exampleName, setExampleName] = useState('')
useEffect(() => {
Expand Down

0 comments on commit ef25ccc

Please sign in to comment.