Skip to content

Commit

Permalink
fixed twenty website build (#5174)
Browse files Browse the repository at this point in the history
Made code compile during build even when then environment variable is
not yet available

Co-authored-by: Ady Beraud <[email protected]>
  • Loading branch information
ady-beraud and ady-test authored Apr 25, 2024
1 parent d23e02a commit 6e8c6c8
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { savePRsToDB } from '@/github-sync/contributors/save-prs-to-db';
import { searchIssuesPRs } from '@/github-sync/contributors/search-issues-prs';
import { IssueNode, PullRequestNode } from '@/github-sync/contributors/types';

export const dynamic = 'force-dynamic';

export async function GET() {
if (!global.process.env.GITHUB_TOKEN) {
return new Response('No GitHub token provided', { status: 500 });
Expand Down
2 changes: 2 additions & 0 deletions packages/twenty-website/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import EmotionRootStyleRegistry from './emotion-root-style-registry';

import './layout.css';

export const dynamic = 'force-dynamic';

export const metadata: Metadata = {
title: 'Twenty.com',
description: 'Open Source CRM',
Expand Down
2 changes: 2 additions & 0 deletions packages/twenty-website/src/app/oss-friends/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const metadata = {
icons: '/images/core/logo.svg',
};

export const dynamic = 'force-dynamic';

export default async function OssFriends() {
const ossList = await fetch('https://formbricks.com/api/oss-friends');

Expand Down
2 changes: 2 additions & 0 deletions packages/twenty-website/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ContentContainer } from './_components/ui/layout/ContentContainer';

export const dynamic = 'force-dynamic';

export default function Home() {
return (
<ContentContainer>
Expand Down
2 changes: 2 additions & 0 deletions packages/twenty-website/src/app/releases/api/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export interface ReleaseNote {
content: string;
}

export const dynamic = 'force-dynamic';

export async function GET(request: NextRequest) {
const host = request.nextUrl.hostname;
const protocol = request.nextUrl.protocol;
Expand Down
2 changes: 2 additions & 0 deletions packages/twenty-website/src/app/releases/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const metadata: Metadata = {
'Discover the newest features and improvements in Twenty, the #1 open-source CRM.',
};

export const dynamic = 'force-dynamic';

const Home = async () => {
const releases = await getReleases();
const mdxReleasesContent = await getMdxReleasesContent(releases);
Expand Down
2 changes: 2 additions & 0 deletions packages/twenty-website/src/app/user-guide/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import UserGuideContent from '@/app/_components/user-guide/UserGuideContent';
import { fetchArticleFromSlug } from '@/shared-utils/fetchArticleFromSlug';
import { formatSlug } from '@/shared-utils/formatSlug';

export const dynamic = 'force-dynamic';

export async function generateMetadata({
params,
}: {
Expand Down
2 changes: 2 additions & 0 deletions packages/twenty-website/src/app/user-guide/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export const metadata = {
icons: '/images/core/logo.svg',
};

export const dynamic = 'force-dynamic';

export default async function UserGuideHome() {
return <UserGuideMain />;
}
10 changes: 7 additions & 3 deletions packages/twenty-website/src/database/database.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { global } from '@apollo/client/utilities/globals';
import { drizzle } from 'drizzle-orm/postgres-js';
import { drizzle, PostgresJsDatabase } from 'drizzle-orm/postgres-js';
import { migrate as postgresMigrate } from 'drizzle-orm/postgres-js/migrator';
import postgres from 'postgres';

import 'dotenv/config';

const pgClient = postgres(`${global.process.env.DATABASE_PG_URL}`);
const pgDb = drizzle(pgClient, { logger: false });
let pgDb: PostgresJsDatabase;

if (global.process.env.DATABASE_PG_URL) {
const pgClient = postgres(`${global.process.env.DATABASE_PG_URL}`);
pgDb = drizzle(pgClient, { logger: false });
}

const migrate = async () => {
await postgresMigrate(pgDb, {
Expand Down

0 comments on commit 6e8c6c8

Please sign in to comment.