mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-08 13:05:08 +09:00
add breakpoints rest
This commit is contained in:
1 parent
1b0ea2adf9
commit
1388f7be67
2 files changed
+28
-1
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { type LoaderFunction } from "remix";
|
||||
import type { Breakpoint } from "@webstudio-is/sdk";
|
||||
import * as db from "~/shared/db";
|
||||
|
||||
export type ErrorData = {
|
||||
errors: string;
|
||||
};
|
||||
|
||||
export const loader: LoaderFunction = async ({
|
||||
params,
|
||||
}): Promise<Array<Breakpoint> | ErrorData> => {
|
||||
try {
|
||||
const data = await db.breakpoints.load(params.projectId);
|
||||
return data?.values || [];
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
errors: error.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
return { errors: "Unexpected error" };
|
||||
};
|
||||
@@ -8,7 +8,11 @@ import ObjectId from "bson-objectid";
|
||||
import { applyPatches, type Patch } from "immer";
|
||||
import { prisma } from "./prisma.server";
|
||||
|
||||
export const load = async (projectId: Project["id"]) => {
|
||||
export const load = async (projectId?: Project["id"]) => {
|
||||
if (typeof projectId !== "string") {
|
||||
throw new Error("Project ID required");
|
||||
}
|
||||
|
||||
return await prisma.breakpoints.findUnique({
|
||||
where: { projectId },
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user