Skip to content

Commit ef31a2f

Browse files
committed
fix(ci): fixed container registry name in ci, modified some routes to be dynamic to avoid nextjs telemetry
1 parent 717e17d commit ef31a2f

File tree

9 files changed

+46
-42
lines changed

9 files changed

+46
-42
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
if: github.event_name != 'pull_request'
3535
uses: docker/login-action@v3
3636
with:
37-
registry: simstudioai
37+
registry: ghcr.io
3838
username: ${{ github.repository_owner }}
3939
password: ${{ secrets.GITHUB_TOKEN }}
4040

apps/sim/app/api/function/execute/route.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { createContext, Script } from 'vm'
44
import { env } from '@/lib/env'
55
import { createLogger } from '@/lib/logs/console-logger'
66

7-
// Explicitly export allowed methods
8-
export const dynamic = 'force-dynamic' // Disable static optimization
9-
export const runtime = 'nodejs' // Use Node.js runtime
7+
export const dynamic = 'force-dynamic'
8+
export const runtime = 'nodejs'
109

1110
const logger = createLogger('FunctionExecuteAPI')
1211

apps/sim/app/api/webhooks/trigger/[path]/route.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ import { webhook, workflow } from '@/db/schema'
1717

1818
const logger = createLogger('WebhookTriggerAPI')
1919

20-
// Define Next.js config for webhook processing
21-
export const dynamic = 'force-dynamic' // Ensure dynamic rendering
22-
export const maxDuration = 300 // 5 minutes max execution time
20+
export const dynamic = 'force-dynamic'
21+
export const maxDuration = 300
2322

24-
// Storage for active processing tasks to prevent garbage collection
2523
const activeProcessingTasks = new Map<string, Promise<any>>()
2624

2725
/**

apps/sim/app/api/workspaces/invitations/accept/route.ts

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { NextRequest, NextResponse } from 'next/server'
22
import { randomUUID } from 'crypto'
33
import { and, eq } from 'drizzle-orm'
44
import { getSession } from '@/lib/auth'
5+
import { env } from '@/lib/env'
56
import { db } from '@/db'
67
import { user, workspace, workspaceInvitation, workspaceMember } from '@/db/schema'
78

8-
// GET /api/workspaces/invitations/accept - Accept an invitation via token
9+
// Accept an invitation via token
910
export async function GET(req: NextRequest) {
1011
const token = req.nextUrl.searchParams.get('token')
1112

@@ -14,7 +15,7 @@ export async function GET(req: NextRequest) {
1415
return NextResponse.redirect(
1516
new URL(
1617
'/invite/invite-error?reason=missing-token',
17-
process.env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
18+
env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
1819
)
1920
)
2021
}
@@ -25,10 +26,7 @@ export async function GET(req: NextRequest) {
2526
// No need to encode API URL as callback, just redirect to invite page
2627
// The middleware will handle proper login flow and return to invite page
2728
return NextResponse.redirect(
28-
new URL(
29-
`/invite/${token}?token=${token}`,
30-
process.env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
31-
)
29+
new URL(`/invite/${token}?token=${token}`, env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai')
3230
)
3331
}
3432

@@ -44,7 +42,7 @@ export async function GET(req: NextRequest) {
4442
return NextResponse.redirect(
4543
new URL(
4644
'/invite/invite-error?reason=invalid-token',
47-
process.env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
45+
env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
4846
)
4947
)
5048
}
@@ -54,7 +52,7 @@ export async function GET(req: NextRequest) {
5452
return NextResponse.redirect(
5553
new URL(
5654
'/invite/invite-error?reason=expired',
57-
process.env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
55+
env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
5856
)
5957
)
6058
}
@@ -64,7 +62,7 @@ export async function GET(req: NextRequest) {
6462
return NextResponse.redirect(
6563
new URL(
6664
'/invite/invite-error?reason=already-processed',
67-
process.env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
65+
env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
6866
)
6967
)
7068
}
@@ -107,7 +105,7 @@ export async function GET(req: NextRequest) {
107105
return NextResponse.redirect(
108106
new URL(
109107
`/invite/invite-error?reason=email-mismatch&details=${encodeURIComponent(`Invitation was sent to ${invitation.email}, but you're logged in as ${userData?.email || session.user.email}`)}`,
110-
process.env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
108+
env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
111109
)
112110
)
113111
}
@@ -123,7 +121,7 @@ export async function GET(req: NextRequest) {
123121
return NextResponse.redirect(
124122
new URL(
125123
'/invite/invite-error?reason=workspace-not-found',
126-
process.env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
124+
env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
127125
)
128126
)
129127
}
@@ -151,10 +149,7 @@ export async function GET(req: NextRequest) {
151149
.where(eq(workspaceInvitation.id, invitation.id))
152150

153151
return NextResponse.redirect(
154-
new URL(
155-
`/w/${invitation.workspaceId}`,
156-
process.env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
157-
)
152+
new URL(`/w/${invitation.workspaceId}`, env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai')
158153
)
159154
}
160155

@@ -179,17 +174,14 @@ export async function GET(req: NextRequest) {
179174

180175
// Redirect to the workspace
181176
return NextResponse.redirect(
182-
new URL(
183-
`/w/${invitation.workspaceId}`,
184-
process.env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
185-
)
177+
new URL(`/w/${invitation.workspaceId}`, env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai')
186178
)
187179
} catch (error) {
188180
console.error('Error accepting invitation:', error)
189181
return NextResponse.redirect(
190182
new URL(
191183
'/invite/invite-error?reason=server-error',
192-
process.env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
184+
env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
193185
)
194186
)
195187
}

apps/sim/app/api/workspaces/invitations/details/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { NextRequest, NextResponse } from 'next/server'
2-
import { and, eq } from 'drizzle-orm'
2+
import { eq } from 'drizzle-orm'
33
import { getSession } from '@/lib/auth'
44
import { db } from '@/db'
55
import { workspace, workspaceInvitation } from '@/db/schema'
66

7-
// GET /api/workspaces/invitations/details - Get invitation details by token
7+
// Get invitation details by token
88
export async function GET(req: NextRequest) {
99
const token = req.nextUrl.searchParams.get('token')
1010

apps/sim/app/api/workspaces/invitations/route.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import { NextRequest, NextResponse } from 'next/server'
22
import { render } from '@react-email/render'
33
import { randomUUID } from 'crypto'
4-
import { and, eq, inArray, sql } from 'drizzle-orm'
4+
import { and, eq, inArray } from 'drizzle-orm'
55
import { Resend } from 'resend'
66
import { WorkspaceInvitationEmail } from '@/components/emails/workspace-invitation'
77
import { getSession } from '@/lib/auth'
8+
import { env } from '@/lib/env'
9+
import { createLogger } from '@/lib/logs/console-logger'
810
import { db } from '@/db'
911
import { user, workspace, workspaceInvitation, workspaceMember } from '@/db/schema'
1012

11-
// Initialize Resend for email sending
12-
const resend = new Resend(process.env.RESEND_API_KEY)
13+
export const dynamic = 'force-dynamic'
1314

14-
// GET /api/workspaces/invitations - Get all invitations for the user's workspaces
15+
const logger = createLogger('WorkspaceInvitationsAPI')
16+
const resend = env.RESEND_API_KEY ? new Resend(env.RESEND_API_KEY) : null
17+
18+
// Get all invitations for the user's workspaces
1519
export async function GET(req: NextRequest) {
1620
const session = await getSession()
1721

@@ -53,7 +57,7 @@ export async function GET(req: NextRequest) {
5357
}
5458
}
5559

56-
// POST /api/workspaces/invitations - Create a new invitation
60+
// Create a new invitation
5761
export async function POST(req: NextRequest) {
5862
const session = await getSession()
5963

@@ -204,7 +208,7 @@ async function sendInvitationEmail({
204208
token: string
205209
}) {
206210
try {
207-
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
211+
const baseUrl = env.NEXT_PUBLIC_APP_URL || 'https://simstudio.ai'
208212
// Always use the client-side invite route with token parameter
209213
const invitationLink = `${baseUrl}/invite/${token}?token=${token}`
210214

@@ -216,8 +220,19 @@ async function sendInvitationEmail({
216220
})
217221
)
218222

223+
if (!resend) {
224+
logger.error(`RESEND_API_KEY not configured`)
225+
return NextResponse.json(
226+
{
227+
error:
228+
'Email service not configured. Please set RESEND_API_KEY in environment variables.',
229+
},
230+
{ status: 500 }
231+
)
232+
}
233+
219234
await resend.emails.send({
220-
from: process.env.RESEND_FROM_EMAIL || 'noreply@simstudio.ai',
235+
from: 'noreply@simstudio.ai',
221236
to,
222237
subject: `You've been invited to join "${workspaceName}" on Sim Studio`,
223238
html: emailHtml,

apps/sim/app/api/workspaces/members/[id]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { NextRequest, NextResponse } from 'next/server'
22
import { and, eq } from 'drizzle-orm'
33
import { getSession } from '@/lib/auth'
44
import { db } from '@/db'
5-
import { workspace, workspaceMember } from '@/db/schema'
5+
import { workspaceMember } from '@/db/schema'
66

7-
// PATCH /api/workspaces/members/[id] - Update a member's role
7+
// Update a member's role
88
export async function PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
99
const { id } = await params
1010
const session = await getSession()

apps/sim/app/api/workspaces/members/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { NextResponse } from 'next/server'
22
import { and, eq } from 'drizzle-orm'
33
import { getSession } from '@/lib/auth'
44
import { db } from '@/db'
5-
import { user, workspace, workspaceMember } from '@/db/schema'
5+
import { user, workspaceMember } from '@/db/schema'
66

7-
// POST /api/workspaces/members - Add a member to a workspace
7+
// Add a member to a workspace
88
export async function POST(req: Request) {
99
const session = await getSession()
1010

apps/sim/app/api/workspaces/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getSession } from '@/lib/auth'
44
import { db } from '@/db'
55
import { workflow, workspace, workspaceMember } from '@/db/schema'
66

7-
// GET /api/workspaces - Get all workspaces for the current user
7+
// Get all workspaces for the current user
88
export async function GET() {
99
const session = await getSession()
1010

0 commit comments

Comments
 (0)