-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c401cf
commit 558fa50
Showing
8 changed files
with
144 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ COPY . . | |
EXPOSE 8080 | ||
|
||
RUN npm run build | ||
CMD [ "npm", "run", "start" ] | ||
CMD ["npm", "run", "build"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { defineEventHandler, createError, readMultipartFormData } from "h3"; | ||
import { connectDB } from "~~/server/db/mongo"; | ||
import { getDxfArray } from "~~/server/utils/multipart"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
try { | ||
const fields = await readMultipartFormData(event); | ||
const dxfFileFields = fields.filter((field) => field.name === "dxf"); | ||
const dxfStrings = getDxfArray(dxfFileFields); | ||
|
||
const db = await connectDB(); | ||
await db.collection("nesting").insertOne({ | ||
dxf: dxfStrings, | ||
uploadedAt: new Date(), | ||
}); | ||
|
||
return { | ||
message: "Nest start", | ||
}; | ||
} catch (err) { | ||
console.error(err); | ||
throw createError({ statusCode: 500, message: err.message }); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export function getDxfArray(fields) { | ||
return fields.map((field) => { | ||
const dxfBuffer = field.data; | ||
if (!dxfBuffer) { | ||
throw createError({ | ||
statusCode: 400, | ||
message: "DXF file is required.", | ||
}); | ||
} | ||
|
||
const dxfString = dxfBuffer.toString(); | ||
|
||
return { | ||
filename: field.filename, | ||
data: dxfString, | ||
}; | ||
}); | ||
} |