Skip to content

feat: move publish to server-side#2338

Merged
Kitenite merged 16 commits into
mainfrom
feat/publish-server-side-1
Jul 3, 2025
Merged

feat: move publish to server-side#2338
Kitenite merged 16 commits into
mainfrom
feat/publish-server-side-1

Conversation

@Kitenite

@Kitenite Kitenite commented Jul 3, 2025

Copy link
Copy Markdown
Contributor

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Release
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes


Important

Move publish functionality to server-side with new deployment architecture and API.

  • Behavior:
    • Move publish logic to server-side using publishRouter in routers/publish/index.ts.
    • Introduce DeploymentType and DeploymentStatus enums in models/hosting/index.ts.
    • Add server-side deployment handling in helpers.ts and manager.ts.
  • API:
    • Add publishRouter to api/root.ts and routers/index.ts.
    • Implement deploymentRouter in routers/publish/deployment.ts for deployment queries and updates.
    • Add forkBuildSandbox in routers/publish/fork.ts for sandbox management.
  • Database:
    • Add deployments table schema in schema/project/deployment.ts.
    • Use drizzle-orm for database operations.
  • Client:
    • Replace client-side publish logic with server-side API calls in custom-domain-section.tsx, preview-domain-section.tsx, and trigger-button.tsx.
    • Introduce HostingProvider and useHostingType in store/hosting for state management.
    • Update providers.tsx to include HostingProvider.

This description was created by Ellipsis for eb7dbdc. You can customize this summary. It will automatically update as commits are pushed.

@vercel

vercel Bot commented Jul 3, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2025 10:53pm
web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2025 10:53pm

@supabase

supabase Bot commented Jul 3, 2025

Copy link
Copy Markdown

This pull request has been ignored for the connected project wowaemfasoptxrdjhilu because there are no changes detected in apps/backend/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

envVars: {},
});

// TODO: handle response

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The publish() function has a TODO comment regarding response handling. Consider checking and handling the response (errors/success) from publish API instead of always showing a success toast.

Comment thread apps/web/client/src/server/api/routers/publish/index.ts

async unpublish(projectId: string, urls: string[]): Promise<PublishResponse> {
try {
const success = await deployFreestyle(PublishType.UNPUBLISH, projectId, {}, urls);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the unpublish method, deployFreestyle is called with incorrect arguments. It’s missing the DB connection as the first parameter, and the config object is not structured correctly. Adjust the call to match the deployFreestyle signature.

Suggested change
const success = await deployFreestyle(PublishType.UNPUBLISH, projectId, {}, urls);
const success = await deployFreestyle(this.session.db, PublishType.UNPUBLISH, projectId, {}, { domains: urls });

Comment on lines +53 to +62
const response = await publishManager.publish({
type,
projectId,
buildScript,
buildFlags,
envVars,
});



Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The publish mutation doesn't return a response to the client. After calling publishManager.publish(), the response should be returned to complete the API contract. Add:

return response;

after line 59 to ensure the client receives the publish operation result.

Suggested change
const response = await publishManager.publish({
type,
projectId,
buildScript,
buildFlags,
envVars,
});
const response = await publishManager.publish({
type,
projectId,
buildScript,
buildFlags,
envVars,
});
return response;

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.


async unpublish(projectId: string, urls: string[]): Promise<PublishResponse> {
try {
const success = await deployFreestyle(PublishType.UNPUBLISH, projectId, {}, urls);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deployFreestyle function call is missing required parameters. The correct function signature requires the database connection as the first parameter:

const success = await deployFreestyle(
  this.session.db, 
  PublishType.UNPUBLISH, 
  projectId, 
  {}, 
  { 
    domains: urls, 
    entrypoint: 'server.js' 
  }
);

This matches the implementation in the deploy.ts file where the first parameter is the database connection.

Suggested change
const success = await deployFreestyle(PublishType.UNPUBLISH, projectId, {}, urls);
const success = await deployFreestyle(
this.session.db,
PublishType.UNPUBLISH,
projectId,
{},
{ domains: urls, entrypoint: 'server.js' }
);

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +53 to +59
const response = await publishManager.publish({
type,
projectId,
buildScript,
buildFlags,
envVars,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The publishManager.publish() call is missing several required parameters according to the function signature in the manager.ts file. Please add the following parameters to complete the call:

const response = await publishManager.publish({
    type,
    projectId,
    buildScript,
    buildFlags,
    envVars,
    urls: foundPreviewDomains.map(d => d.fullDomain),
    skipBadge: false,
    skipBuild: false
});

Without these parameters, the publish operation will fail when it attempts to access them.

Suggested change
const response = await publishManager.publish({
type,
projectId,
buildScript,
buildFlags,
envVars,
});
const response = await publishManager.publish({
type,
projectId,
buildScript,
buildFlags,
envVars,
urls: foundPreviewDomains.map(d => d.fullDomain),
skipBadge: false,
skipBuild: false
});

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

}

// Deploy to Freestyle
deployFreestyle({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deployFreestyle call isn’t awaited. Use 'await' so that any deployment errors are properly handled before the procedure completes.

Suggested change
deployFreestyle({
await deployFreestyle({

// Run domain check

// Delete deployment
deployFreestyle({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unpublish deployFreestyle call isn’t awaited. Await it to catch asynchronous errors during deletion.

Suggested change
deployFreestyle({
await deployFreestyle({

}),

unpublish: publicProcedure.input(z.object({
type: z.nativeEnum(PublishType),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unpublish procedure’s input includes a 'type' field that isn’t used. Consider removing it if unnecessary.

Suggested change
type: z.nativeEnum(PublishType),

Comment thread apps/web/client/src/server/api/routers/publish/index.ts
const unpublish = async (projectId: string, type: DeploymentType) => {
const response = await runUnpublish({
projectId,
type: DeploymentType.UNPUBLISH_ALL,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unpublish function always sets the type to DeploymentType.UNPUBLISH_ALL, ignoring the passed type parameter. This seems unintended given downstream calls expect specific unpublish types.

Suggested change
type: DeploymentType.UNPUBLISH_ALL,
type,

Comment on lines +189 to +193
deployFreestyle({
files,
urls: deploymentUrls,
envVars,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deployFreestyle() function returns a Promise but is being called without await. This could lead to the function continuing execution before deployment is complete, potentially causing the cleanup to start prematurely. Consider modifying to:

const result = await deployFreestyle({
    files,
    urls: deploymentUrls,
    envVars,
});

This ensures the deployment completes before moving to cleanup steps and would also allow checking the result for success/failure.

Suggested change
deployFreestyle({
files,
urls: deploymentUrls,
envVars,
});
const result = await deployFreestyle({
files,
urls: deploymentUrls,
envVars,
});

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Comment thread apps/web/client/src/server/api/routers/publish/index.ts Outdated
Comment thread apps/web/client/src/server/api/routers/publish/helpers.ts
Comment thread apps/web/client/src/server/api/routers/publish/helpers.ts Outdated
Comment thread apps/web/client/src/server/api/routers/publish/helpers.ts
@Kitenite
Kitenite merged commit 836b68c into main Jul 3, 2025
6 checks passed
@Kitenite
Kitenite deleted the feat/publish-server-side-1 branch July 3, 2025 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant