Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
use promises everywhere
Sara Vieira5d740c90e9ba
diff --git a/apps/designer/app/routes/designer/$id.tsx b/apps/designer/app/routes/designer/$id.tsxindex 85764d6268..5a020bb54d 100644--- a/apps/designer/app/routes/designer/$id.tsx+++ b/apps/designer/app/routes/designer/$id.tsx@@ -53,16 +53,20 @@ export const action: ActionFunction = async ({ request, params }) => {const imagesInfo = ImagesUpload.parse(formData.getAll("image"));- imagesInfo.forEach((image) => {+ const allInfo = imagesInfo.map(async (image) => {const data = {name: image.name,path: `${path.join("/", folderInPublic, image.name)}`,};const absolutePath = path.join(directory, image.name);const projectId = params.id as string;- db.assets.create(projectId, data, absolutePath);+ const newAsset = await db.assets.create(projectId, data, absolutePath);++ return newAsset;});+ await Promise.all(allInfo);+return {ok: true,};diff --git a/apps/designer/app/shared/db/assets.server.ts b/apps/designer/app/shared/db/assets.server.tsindex ece4d1f87b..a1ecb22991 100644--- a/apps/designer/app/shared/db/assets.server.ts+++ b/apps/designer/app/shared/db/assets.server.ts@@ -1,7 +1,7 @@import { type Project } from "@webstudio-is/react-sdk";import { prisma } from "./prisma.server";import sharp from "sharp";-import fs from "fs";+import fsPromises from "fs/promises";import { fetch } from "@remix-run/node";export const loadByProject = async (projectId?: Project["id"]) => {@@ -27,7 +27,7 @@ export const create = async (// if there is no absolute path then it means it's a remote image and we can use fetchif (absolutePath) {- size = fs.statSync(absolutePath).size;+ size = await (await fsPromises.stat(absolutePath)).size;} else {const arrayBuffer = await fetch(values.path).then((rsp) =>rsp.arrayBuffer()