2
0

Revert "fix(docker): 🐛 Runtime public environment"

This reverts commit e03fe9f7d9.
This commit is contained in:
Baptiste Arnaud
2022-06-22 07:21:02 +02:00
parent e03fe9f7d9
commit 3e47b37c2e
54 changed files with 164 additions and 349 deletions

View File

@@ -1,7 +1,7 @@
import { CollaborationType, Plan, Prisma, User, WorkspaceRole } from 'db'
import prisma from 'libs/prisma'
import { NextApiResponse } from 'next'
import { env, forbidden, isNotEmpty } from 'utils'
import { forbidden, isNotEmpty } from 'utils'
const parseWhereFilter = (
typebotIds: string[] | string,
@@ -22,7 +22,7 @@ const parseWhereFilter = (
id: typeof typebotIds === 'string' ? typebotIds : { in: typebotIds },
workspace:
(type === 'read' && user.email === process.env.ADMIN_EMAIL) ||
isNotEmpty(env('E2E_TEST'))
isNotEmpty(process.env.NEXT_PUBLIC_E2E_TEST)
? undefined
: {
members: {

View File

@@ -1,5 +1,4 @@
import { createTransport } from 'nodemailer'
import { env } from 'utils'
export const sendEmailNotification = ({
to,
@@ -20,7 +19,7 @@ export const sendEmailNotification = ({
})
return transporter.sendMail({
from: env('SMTP_FORM'),
from: process.env.NEXT_PUBLIC_SMTP_FROM,
to,
subject,
html: content,

View File

@@ -2,7 +2,7 @@ import { DashboardFolder } from 'db'
import useSWR from 'swr'
import { fetcher } from './utils'
import { stringify } from 'qs'
import { env, sendRequest } from 'utils'
import { isNotEmpty, sendRequest } from 'utils'
export const useFolders = ({
parentId,
@@ -18,7 +18,9 @@ export const useFolders = ({
workspaceId ? `/api/folders?${params}` : null,
fetcher,
{
dedupingInterval: env('E2E_TEST') === 'enabled' ? 0 : undefined,
dedupingInterval: isNotEmpty(process.env.NEXT_PUBLIC_E2E_TEST)
? 0
: undefined,
}
)
if (error) onError(error)

View File

@@ -1,4 +1,4 @@
import { env, sendRequest } from 'utils'
import { sendRequest } from 'utils'
import { stringify } from 'qs'
import useSWR from 'swr'
import { fetcher } from './utils'
@@ -78,9 +78,7 @@ export const executeWebhook = (
{ blockId }: { blockId: string }
) =>
sendRequest<WebhookResponse>({
url: `${env(
'VIEWER_URL'
)}/api/typebots/${typebotId}/blocks/${blockId}/executeWebhook`,
url: `${process.env.NEXT_PUBLIC_VIEWER_URL}/api/typebots/${typebotId}/blocks/${blockId}/executeWebhook`,
method: 'POST',
body: {
variables,

View File

@@ -1,6 +1,7 @@
import { Plan, User } from 'db'
import { loadStripe } from '@stripe/stripe-js/pure'
import { env, isDefined, isEmpty, sendRequest } from 'utils'
import { isDefined, isEmpty, sendRequest } from 'utils'
import getConfig from 'next/config'
type Props = {
user: User
@@ -39,7 +40,10 @@ const redirectToCheckout = async ({
plan,
workspaceId,
}: Omit<Props, 'customerId'>) => {
if (isEmpty(env('STRIPE_PUBLIC_KEY')))
const {
publicRuntimeConfig: { NEXT_PUBLIC_STRIPE_PUBLIC_KEY },
} = getConfig()
if (isEmpty(NEXT_PUBLIC_STRIPE_PUBLIC_KEY))
throw new Error('NEXT_PUBLIC_STRIPE_PUBLIC_KEY is missing in env')
const { data, error } = await sendRequest<{ sessionId: string }>({
method: 'POST',
@@ -53,7 +57,7 @@ const redirectToCheckout = async ({
},
})
if (error || !data) return
const stripe = await loadStripe(env('STRIPE_PUBLIC_KEY') as string)
const stripe = await loadStripe(NEXT_PUBLIC_STRIPE_PUBLIC_KEY)
await stripe?.redirectToCheckout({
sessionId: data?.sessionId,
})

View File

@@ -1,7 +1,7 @@
import { CollaborationType, Invitation } from 'db'
import { fetcher } from 'services/utils'
import useSWR from 'swr'
import { env, sendRequest } from 'utils'
import { isNotEmpty, sendRequest } from 'utils'
export const useInvitations = ({
typebotId,
@@ -14,7 +14,9 @@ export const useInvitations = ({
typebotId ? `/api/typebots/${typebotId}/invitations` : null,
fetcher,
{
dedupingInterval: env('E2E_TEST') === 'enabled' ? 0 : undefined,
dedupingInterval: isNotEmpty(process.env.NEXT_PUBLIC_E2E_TEST)
? 0
: undefined,
}
)
if (error) onError(error)

View File

@@ -7,7 +7,7 @@ import {
import useSWRInfinite from 'swr/infinite'
import { stringify } from 'qs'
import { Answer } from 'db'
import { env, isDefined, sendRequest } from 'utils'
import { isDefined, isEmpty, sendRequest } from 'utils'
import { fetcher } from 'services/utils'
import { HStack, Text, Wrap, WrapItem } from '@chakra-ui/react'
import { CodeIcon, CalendarIcon, FileIcon } from 'assets/icons'
@@ -54,7 +54,9 @@ export const useResults = ({
fetcher,
{
revalidateAll: true,
dedupingInterval: env('E2E_TEST') === 'enabled' ? 0 : undefined,
dedupingInterval: isEmpty(process.env.NEXT_PUBLIC_E2E_TEST)
? undefined
: 0,
}
)

View File

@@ -46,13 +46,13 @@ import useSWR from 'swr'
import { fetcher, toKebabCase } from '../utils'
import {
isBubbleBlockType,
isNotEmpty,
isWebhookBlock,
omit,
blockHasItems,
blockTypeHasItems,
blockTypeHasOption,
blockTypeHasWebhook,
env,
} from 'utils'
import { dequal } from 'dequal'
import { stringify } from 'qs'
@@ -83,7 +83,9 @@ export const useTypebots = ({
{ typebots: TypebotInDashboard[] },
Error
>(workspaceId ? `/api/typebots?${params}` : null, fetcher, {
dedupingInterval: env('E2E_TEST') === 'enabled' ? 0 : undefined,
dedupingInterval: isNotEmpty(process.env.NEXT_PUBLIC_E2E_TEST)
? 0
: undefined,
})
if (error) onError(error)
return {

View File

@@ -1,7 +1,7 @@
import { ApiToken } from 'db'
import { fetcher } from 'services/utils'
import useSWR, { KeyedMutator } from 'swr'
import { env, sendRequest } from 'utils'
import { isNotEmpty, sendRequest } from 'utils'
export type ApiTokenFromServer = { id: string; name: string; createdAt: string }
@@ -25,7 +25,9 @@ export const useApiTokens = ({
userId ? `/api/users/${userId}/api-tokens` : null,
fetcher,
{
dedupingInterval: env('E2E_TEST') === 'enabled' ? 0 : undefined,
dedupingInterval: isNotEmpty(process.env.NEXT_PUBLIC_E2E_TEST)
? 0
: undefined,
}
)
if (error) onError(error)

View File

@@ -1,7 +1,7 @@
import { MemberInWorkspace, WorkspaceInvitation } from 'db'
import { fetcher } from 'services/utils'
import useSWR from 'swr'
import { env, sendRequest } from 'utils'
import { isEmpty, sendRequest } from 'utils'
export type Member = MemberInWorkspace & {
name: string | null
@@ -14,7 +14,7 @@ export const useMembers = ({ workspaceId }: { workspaceId?: string }) => {
{ members: Member[]; invitations: WorkspaceInvitation[] },
Error
>(workspaceId ? `/api/workspaces/${workspaceId}/members` : null, fetcher, {
dedupingInterval: env('E2E_TEST') === 'enabled' ? 0 : undefined,
dedupingInterval: isEmpty(process.env.NEXT_PUBLIC_E2E_TEST) ? undefined : 0,
})
return {
members: data?.members,