kalhdrawi commited on
Commit
4a3e131
·
1 Parent(s): 2271467

Reupload OmniDev clean version

Browse files
app/api/me/projects/[namespace]/[repoId]/route.ts CHANGED
@@ -1,5 +1,6 @@
1
  import { NextRequest, NextResponse } from "next/server";
2
  import { RepoDesignation, spaceInfo, listFiles, deleteRepo, listCommits, downloadFile } from "@huggingface/hub";
 
3
 
4
  import { isAuthenticated } from "@/lib/auth";
5
  import { Commit, Page } from "@/types";
@@ -23,13 +24,7 @@ export async function DELETE(
23
  accessToken: user.token as string,
24
  additionalFields: ["author"],
25
  });
26
-
27
- if (!space || space.sdk !== "static") {
28
- return NextResponse.json(
29
- { ok: false, error: "Space is not a static space." },
30
- { status: 404 }
31
- );
32
- }
33
 
34
  if (space.author !== user.name) {
35
  return NextResponse.json(
@@ -78,15 +73,7 @@ export async function GET(
78
  additionalFields: ["author"],
79
  });
80
 
81
- if (!space || space.sdk !== "static") {
82
- return NextResponse.json(
83
- {
84
- ok: false,
85
- error: "Space is not a static space",
86
- },
87
- { status: 404 }
88
- );
89
- }
90
  if (space.author !== user.name) {
91
  return NextResponse.json(
92
  {
@@ -146,14 +133,9 @@ export async function GET(
146
  });
147
  }
148
 
 
149
  if (htmlFiles.length === 0) {
150
- return NextResponse.json(
151
- {
152
- ok: false,
153
- error: "No HTML files found",
154
- },
155
- { status: 404 }
156
- );
157
  }
158
  return NextResponse.json(
159
  {
 
1
  import { NextRequest, NextResponse } from "next/server";
2
  import { RepoDesignation, spaceInfo, listFiles, deleteRepo, listCommits, downloadFile } from "@huggingface/hub";
3
+ import { defaultHTML } from "@/lib/consts";
4
 
5
  import { isAuthenticated } from "@/lib/auth";
6
  import { Commit, Page } from "@/types";
 
24
  accessToken: user.token as string,
25
  additionalFields: ["author"],
26
  });
27
+ // Allow any SDK; do not restrict to "static" so projects with node/docker can be loaded and edited.
 
 
 
 
 
 
28
 
29
  if (space.author !== user.name) {
30
  return NextResponse.json(
 
73
  additionalFields: ["author"],
74
  });
75
 
76
+ // Do not restrict to static SDK here either
 
 
 
 
 
 
 
 
77
  if (space.author !== user.name) {
78
  return NextResponse.json(
79
  {
 
133
  });
134
  }
135
 
136
+ // If there are no HTML files, provide a placeholder so UI can load
137
  if (htmlFiles.length === 0) {
138
+ htmlFiles.push({ path: "index.html", html: defaultHTML });
 
 
 
 
 
 
139
  }
140
  return NextResponse.json(
141
  {