Add s3 integration #317
@@ -1,53 +1,55 @@
|
|||||||
const { runCQ } = require('./runCQ')
|
const { runCQ } = require('./runCQ')
|
||||||
const middy = require('middy')
|
const middy = require('middy')
|
||||||
const { cors } = require('middy/middlewares')
|
const { cors } = require('middy/middlewares')
|
||||||
|
const AWS = require('aws-sdk')
|
||||||
|
const {
|
||||||
|
makeHash,
|
||||||
|
checkIfAlreadyExists,
|
||||||
|
getObjectUrl,
|
||||||
|
loggerWrap,
|
||||||
|
storeAssetAndReturnUrl,
|
||||||
|
} = require('../common/utils')
|
||||||
|
|
||||||
// cors true does not seem to work in serverless.yml, perhaps docker lambdas aren't covered by that config
|
const s3 = new AWS.S3()
|
||||||
// special lambda just for responding to options requests
|
|
||||||
const preflightOptions = (req, _context, callback) => {
|
|
||||||
const response = {
|
|
||||||
statusCode: 204,
|
|
||||||
headers: {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Access-Control-Allow-Methods': 'POST',
|
|
||||||
'Access-Control-Allow-Headers': '*',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
callback(null, response)
|
|
||||||
}
|
|
||||||
|
|
||||||
const stl = async (req, _context, callback) => {
|
const stl = async (req, _context, callback) => {
|
||||||
_context.callbackWaitsForEmptyEventLoop = false
|
_context.callbackWaitsForEmptyEventLoop = false
|
||||||
const eventBody = Buffer.from(req.body, 'base64').toString('ascii')
|
const eventBody = req.body
|
||||||
console.log(eventBody, 'eventBody')
|
console.log('eventBody', eventBody)
|
||||||
const { file, settings } = JSON.parse(eventBody)
|
const key = `${makeHash(eventBody)}.stl`
|
||||||
const { error, result, tempFile } = await runCQ({ file, settings })
|
console.log('key', key)
|
||||||
if (error) {
|
|
||||||
const response = {
|
const params = {
|
||||||
statusCode: 400,
|
Bucket: process.env.BUCKET,
|
||||||
body: JSON.stringify({ error, tempFile }),
|
Key: key,
|
||||||
}
|
}
|
||||||
|
|
|||||||
callback(null, response)
|
const previousAsset = await checkIfAlreadyExists(params, s3)
|
||||||
} else {
|
if (previousAsset.isAlreadyInBucket) {
|
||||||
console.log(`got result in route: ${result}, file is: ${tempFile}`)
|
console.log('already in bucket')
|
||||||
const fs = require('fs')
|
|
||||||
const image = fs.readFileSync(`/tmp/${tempFile}/output.stl`, {
|
|
||||||
encoding: 'base64',
|
|
||||||
})
|
|
||||||
console.log(image, 'encoded image')
|
|
||||||
const response = {
|
const response = {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
imageBase64: image,
|
url: getObjectUrl(params, s3),
|
||||||
result,
|
consoleMessage: previousAsset.consoleMessage,
|
||||||
tempFile,
|
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
callback(null, response)
|
callback(null, response)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { file, settings } = JSON.parse(eventBody)
|
||||||
|
const { error, consoleMessage, fullPath } = await runCQ({ file, settings })
|
||||||
|
await storeAssetAndReturnUrl({
|
||||||
|
error,
|
||||||
|
callback,
|
||||||
|
fullPath,
|
||||||
|
consoleMessage,
|
||||||
|
key,
|
||||||
|
s3,
|
||||||
|
params,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
stl: middy(stl).use(cors()),
|
stl: middy(loggerWrap(stl)).use(cors()),
|
||||||
preflightOptions,
|
|
||||||
}
|
}
|
||||||
|
|||||||
2215
app/api/src/docker/cadquery/package-lock.json
generated
Normal file
@@ -6,6 +6,7 @@
|
|||||||
"author": "Kurt Hutten <kurt@kurthutten.com>",
|
"author": "Kurt Hutten <kurt@kurthutten.com>",
|
||||||
"license": "",
|
"license": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"aws-sdk": "^2.907.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"middy": "^0.36.0",
|
"middy": "^0.36.0",
|
||||||
"nanoid": "^3.1.20"
|
"nanoid": "^3.1.20"
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ const { nanoid } = require('nanoid')
|
|||||||
|
|
||||||
module.exports.runCQ = async ({ file, settings = {} } = {}) => {
|
module.exports.runCQ = async ({ file, settings = {} } = {}) => {
|
||||||
const tempFile = await makeFile(file, '.py', nanoid)
|
const tempFile = await makeFile(file, '.py', nanoid)
|
||||||
const command = `cq-cli/cq-cli --codec stl --infile /tmp/${tempFile}/main.py --outfile /tmp/${tempFile}/output.stl`
|
const fullPath = `/tmp/${tempFile}/output.stl`
|
||||||
|
const command = `cq-cli/cq-cli --codec stl --infile /tmp/${tempFile}/main.py --outfile ${fullPath}`
|
||||||
console.log('command', command)
|
console.log('command', command)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await runCommand(command, 30000)
|
const consoleMessage = await runCommand(command, 30000)
|
||||||
return { result, tempFile }
|
return { consoleMessage, fullPath }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { error, tempFile }
|
return { error, fullPath }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,386 +0,0 @@
|
|||||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
||||||
# yarn lockfile v1
|
|
||||||
|
|
||||||
|
|
||||||
accepts@~1.3.7:
|
|
||||||
version "1.3.7"
|
|
||||||
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd"
|
|
||||||
integrity sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==
|
|
||||||
dependencies:
|
|
||||||
mime-types "~2.1.24"
|
|
||||||
negotiator "0.6.2"
|
|
||||||
|
|
||||||
array-flatten@1.1.1:
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2"
|
|
||||||
integrity sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=
|
|
||||||
|
|
||||||
body-parser@1.19.0:
|
|
||||||
version "1.19.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a"
|
|
||||||
integrity sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==
|
|
||||||
dependencies:
|
|
||||||
bytes "3.1.0"
|
|
||||||
content-type "~1.0.4"
|
|
||||||
debug "2.6.9"
|
|
||||||
depd "~1.1.2"
|
|
||||||
http-errors "1.7.2"
|
|
||||||
iconv-lite "0.4.24"
|
|
||||||
on-finished "~2.3.0"
|
|
||||||
qs "6.7.0"
|
|
||||||
raw-body "2.4.0"
|
|
||||||
type-is "~1.6.17"
|
|
||||||
|
|
||||||
bytes@3.1.0:
|
|
||||||
version "3.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6"
|
|
||||||
integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==
|
|
||||||
|
|
||||||
content-disposition@0.5.3:
|
|
||||||
version "0.5.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd"
|
|
||||||
integrity sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==
|
|
||||||
dependencies:
|
|
||||||
safe-buffer "5.1.2"
|
|
||||||
|
|
||||||
content-type@~1.0.4:
|
|
||||||
version "1.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b"
|
|
||||||
integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==
|
|
||||||
|
|
||||||
cookie-signature@1.0.6:
|
|
||||||
version "1.0.6"
|
|
||||||
resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c"
|
|
||||||
integrity sha1-4wOogrNCzD7oylE6eZmXNNqzriw=
|
|
||||||
|
|
||||||
cookie@0.4.0:
|
|
||||||
version "0.4.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba"
|
|
||||||
integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==
|
|
||||||
|
|
||||||
cors@^2.8.5:
|
|
||||||
version "2.8.5"
|
|
||||||
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
|
|
||||||
integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==
|
|
||||||
dependencies:
|
|
||||||
object-assign "^4"
|
|
||||||
vary "^1"
|
|
||||||
|
|
||||||
debug@2.6.9:
|
|
||||||
version "2.6.9"
|
|
||||||
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
|
|
||||||
integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==
|
|
||||||
dependencies:
|
|
||||||
ms "2.0.0"
|
|
||||||
|
|
||||||
depd@~1.1.2:
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
|
|
||||||
integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=
|
|
||||||
|
|
||||||
destroy@~1.0.4:
|
|
||||||
version "1.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80"
|
|
||||||
integrity sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=
|
|
||||||
|
|
||||||
ee-first@1.1.1:
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
|
|
||||||
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
|
|
||||||
|
|
||||||
encodeurl@~1.0.2:
|
|
||||||
version "1.0.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59"
|
|
||||||
integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=
|
|
||||||
|
|
||||||
escape-html@~1.0.3:
|
|
||||||
version "1.0.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"
|
|
||||||
integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=
|
|
||||||
|
|
||||||
etag@~1.8.1:
|
|
||||||
version "1.8.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887"
|
|
||||||
integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=
|
|
||||||
|
|
||||||
express@^4.17.1:
|
|
||||||
version "4.17.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134"
|
|
||||||
integrity sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==
|
|
||||||
dependencies:
|
|
||||||
accepts "~1.3.7"
|
|
||||||
array-flatten "1.1.1"
|
|
||||||
body-parser "1.19.0"
|
|
||||||
content-disposition "0.5.3"
|
|
||||||
content-type "~1.0.4"
|
|
||||||
cookie "0.4.0"
|
|
||||||
cookie-signature "1.0.6"
|
|
||||||
debug "2.6.9"
|
|
||||||
depd "~1.1.2"
|
|
||||||
encodeurl "~1.0.2"
|
|
||||||
escape-html "~1.0.3"
|
|
||||||
etag "~1.8.1"
|
|
||||||
finalhandler "~1.1.2"
|
|
||||||
fresh "0.5.2"
|
|
||||||
merge-descriptors "1.0.1"
|
|
||||||
methods "~1.1.2"
|
|
||||||
on-finished "~2.3.0"
|
|
||||||
parseurl "~1.3.3"
|
|
||||||
path-to-regexp "0.1.7"
|
|
||||||
proxy-addr "~2.0.5"
|
|
||||||
qs "6.7.0"
|
|
||||||
range-parser "~1.2.1"
|
|
||||||
safe-buffer "5.1.2"
|
|
||||||
send "0.17.1"
|
|
||||||
serve-static "1.14.1"
|
|
||||||
setprototypeof "1.1.1"
|
|
||||||
statuses "~1.5.0"
|
|
||||||
type-is "~1.6.18"
|
|
||||||
utils-merge "1.0.1"
|
|
||||||
vary "~1.1.2"
|
|
||||||
|
|
||||||
finalhandler@~1.1.2:
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d"
|
|
||||||
integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==
|
|
||||||
dependencies:
|
|
||||||
debug "2.6.9"
|
|
||||||
encodeurl "~1.0.2"
|
|
||||||
escape-html "~1.0.3"
|
|
||||||
on-finished "~2.3.0"
|
|
||||||
parseurl "~1.3.3"
|
|
||||||
statuses "~1.5.0"
|
|
||||||
unpipe "~1.0.0"
|
|
||||||
|
|
||||||
forwarded@~0.1.2:
|
|
||||||
version "0.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84"
|
|
||||||
integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=
|
|
||||||
|
|
||||||
fresh@0.5.2:
|
|
||||||
version "0.5.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7"
|
|
||||||
integrity sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=
|
|
||||||
|
|
||||||
http-errors@1.7.2:
|
|
||||||
version "1.7.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.2.tgz#4f5029cf13239f31036e5b2e55292bcfbcc85c8f"
|
|
||||||
integrity sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==
|
|
||||||
dependencies:
|
|
||||||
depd "~1.1.2"
|
|
||||||
inherits "2.0.3"
|
|
||||||
setprototypeof "1.1.1"
|
|
||||||
statuses ">= 1.5.0 < 2"
|
|
||||||
toidentifier "1.0.0"
|
|
||||||
|
|
||||||
http-errors@~1.7.2:
|
|
||||||
version "1.7.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.3.tgz#6c619e4f9c60308c38519498c14fbb10aacebb06"
|
|
||||||
integrity sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==
|
|
||||||
dependencies:
|
|
||||||
depd "~1.1.2"
|
|
||||||
inherits "2.0.4"
|
|
||||||
setprototypeof "1.1.1"
|
|
||||||
statuses ">= 1.5.0 < 2"
|
|
||||||
toidentifier "1.0.0"
|
|
||||||
|
|
||||||
iconv-lite@0.4.24:
|
|
||||||
version "0.4.24"
|
|
||||||
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"
|
|
||||||
integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==
|
|
||||||
dependencies:
|
|
||||||
safer-buffer ">= 2.1.2 < 3"
|
|
||||||
|
|
||||||
inherits@2.0.3:
|
|
||||||
version "2.0.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
|
||||||
integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
|
|
||||||
|
|
||||||
inherits@2.0.4:
|
|
||||||
version "2.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
|
|
||||||
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
|
|
||||||
|
|
||||||
ipaddr.js@1.9.1:
|
|
||||||
version "1.9.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3"
|
|
||||||
integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==
|
|
||||||
|
|
||||||
media-typer@0.3.0:
|
|
||||||
version "0.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
|
|
||||||
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=
|
|
||||||
|
|
||||||
merge-descriptors@1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61"
|
|
||||||
integrity sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=
|
|
||||||
|
|
||||||
methods@~1.1.2:
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
|
|
||||||
integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=
|
|
||||||
|
|
||||||
mime-db@1.46.0:
|
|
||||||
version "1.46.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.46.0.tgz#6267748a7f799594de3cbc8cde91def349661cee"
|
|
||||||
integrity sha512-svXaP8UQRZ5K7or+ZmfNhg2xX3yKDMUzqadsSqi4NCH/KomcH75MAMYAGVlvXn4+b/xOPhS3I2uHKRUzvjY7BQ==
|
|
||||||
|
|
||||||
mime-types@~2.1.24:
|
|
||||||
version "2.1.29"
|
|
||||||
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.29.tgz#1d4ab77da64b91f5f72489df29236563754bb1b2"
|
|
||||||
integrity sha512-Y/jMt/S5sR9OaqteJtslsFZKWOIIqMACsJSiHghlCAyhf7jfVYjKBmLiX8OgpWeW+fjJ2b+Az69aPFPkUOY6xQ==
|
|
||||||
dependencies:
|
|
||||||
mime-db "1.46.0"
|
|
||||||
|
|
||||||
mime@1.6.0:
|
|
||||||
version "1.6.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
|
|
||||||
integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==
|
|
||||||
|
|
||||||
ms@2.0.0:
|
|
||||||
version "2.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
|
|
||||||
integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=
|
|
||||||
|
|
||||||
ms@2.1.1:
|
|
||||||
version "2.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
|
|
||||||
integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==
|
|
||||||
|
|
||||||
nanoid@^3.1.20:
|
|
||||||
version "3.1.20"
|
|
||||||
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.20.tgz#badc263c6b1dcf14b71efaa85f6ab4c1d6cfc788"
|
|
||||||
integrity sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==
|
|
||||||
|
|
||||||
negotiator@0.6.2:
|
|
||||||
version "0.6.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb"
|
|
||||||
integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==
|
|
||||||
|
|
||||||
object-assign@^4:
|
|
||||||
version "4.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
|
||||||
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
|
|
||||||
|
|
||||||
on-finished@~2.3.0:
|
|
||||||
version "2.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947"
|
|
||||||
integrity sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=
|
|
||||||
dependencies:
|
|
||||||
ee-first "1.1.1"
|
|
||||||
|
|
||||||
parseurl@~1.3.3:
|
|
||||||
version "1.3.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4"
|
|
||||||
integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==
|
|
||||||
|
|
||||||
path-to-regexp@0.1.7:
|
|
||||||
version "0.1.7"
|
|
||||||
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
|
|
||||||
integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=
|
|
||||||
|
|
||||||
proxy-addr@~2.0.5:
|
|
||||||
version "2.0.6"
|
|
||||||
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.6.tgz#fdc2336505447d3f2f2c638ed272caf614bbb2bf"
|
|
||||||
integrity sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==
|
|
||||||
dependencies:
|
|
||||||
forwarded "~0.1.2"
|
|
||||||
ipaddr.js "1.9.1"
|
|
||||||
|
|
||||||
qs@6.7.0:
|
|
||||||
version "6.7.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
|
|
||||||
integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==
|
|
||||||
|
|
||||||
range-parser@~1.2.1:
|
|
||||||
version "1.2.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031"
|
|
||||||
integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==
|
|
||||||
|
|
||||||
raw-body@2.4.0:
|
|
||||||
version "2.4.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.0.tgz#a1ce6fb9c9bc356ca52e89256ab59059e13d0332"
|
|
||||||
integrity sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==
|
|
||||||
dependencies:
|
|
||||||
bytes "3.1.0"
|
|
||||||
http-errors "1.7.2"
|
|
||||||
iconv-lite "0.4.24"
|
|
||||||
unpipe "1.0.0"
|
|
||||||
|
|
||||||
safe-buffer@5.1.2:
|
|
||||||
version "5.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
|
|
||||||
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
|
|
||||||
|
|
||||||
"safer-buffer@>= 2.1.2 < 3":
|
|
||||||
version "2.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
|
|
||||||
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
|
|
||||||
|
|
||||||
send@0.17.1:
|
|
||||||
version "0.17.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8"
|
|
||||||
integrity sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==
|
|
||||||
dependencies:
|
|
||||||
debug "2.6.9"
|
|
||||||
depd "~1.1.2"
|
|
||||||
destroy "~1.0.4"
|
|
||||||
encodeurl "~1.0.2"
|
|
||||||
escape-html "~1.0.3"
|
|
||||||
etag "~1.8.1"
|
|
||||||
fresh "0.5.2"
|
|
||||||
http-errors "~1.7.2"
|
|
||||||
mime "1.6.0"
|
|
||||||
ms "2.1.1"
|
|
||||||
on-finished "~2.3.0"
|
|
||||||
range-parser "~1.2.1"
|
|
||||||
statuses "~1.5.0"
|
|
||||||
|
|
||||||
serve-static@1.14.1:
|
|
||||||
version "1.14.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.1.tgz#666e636dc4f010f7ef29970a88a674320898b2f9"
|
|
||||||
integrity sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==
|
|
||||||
dependencies:
|
|
||||||
encodeurl "~1.0.2"
|
|
||||||
escape-html "~1.0.3"
|
|
||||||
parseurl "~1.3.3"
|
|
||||||
send "0.17.1"
|
|
||||||
|
|
||||||
setprototypeof@1.1.1:
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683"
|
|
||||||
integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==
|
|
||||||
|
|
||||||
"statuses@>= 1.5.0 < 2", statuses@~1.5.0:
|
|
||||||
version "1.5.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
|
|
||||||
integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=
|
|
||||||
|
|
||||||
toidentifier@1.0.0:
|
|
||||||
version "1.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"
|
|
||||||
integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
|
|
||||||
|
|
||||||
type-is@~1.6.17, type-is@~1.6.18:
|
|
||||||
version "1.6.18"
|
|
||||||
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131"
|
|
||||||
integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==
|
|
||||||
dependencies:
|
|
||||||
media-typer "0.3.0"
|
|
||||||
mime-types "~2.1.24"
|
|
||||||
|
|
||||||
unpipe@1.0.0, unpipe@~1.0.0:
|
|
||||||
version "1.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
|
|
||||||
integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=
|
|
||||||
|
|
||||||
utils-merge@1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
|
|
||||||
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
|
|
||||||
|
|
||||||
vary@^1, vary@~1.1.2:
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
|
|
||||||
integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=
|
|
||||||
@@ -1,6 +1,19 @@
|
|||||||
const { exec } = require('child_process')
|
const { exec } = require('child_process')
|
||||||
const { promises } = require('fs')
|
const { promises } = require('fs')
|
||||||
const { writeFile } = promises
|
const { writeFile } = promises
|
||||||
|
const { createHash } = require('crypto')
|
||||||
|
|
||||||
|
const CONSOLE_MESSAGE_KEY = 'console-message-b64'
|
||||||
|
function putConsoleMessageInMetadata(consoleMessage) {
|
||||||
|
I'm storing whatever the cad package printed to the terminal when it made the part in metadata, so that I can still display this when returning the cached assets. s3 seems to be pretty sensitive about special characters that can be put in s3 so base64 to the rescue. I'm storing whatever the cad package printed to the terminal when it made the part in metadata, so that I can still display this when returning the cached assets. s3 seems to be pretty sensitive about special characters that can be put in s3 so base64 to the rescue.
Ended up being a bad idea as only 2kb can be store as metadata, and it's definitely possible for logs to exceed this. Ended up being a bad idea as only 2kb can be store as metadata, and it's definitely possible for logs to exceed this.
|
|||||||
|
return {
|
||||||
|
[CONSOLE_MESSAGE_KEY]: Buffer.from(consoleMessage, 'utf-8').toString(
|
||||||
|
'base64'
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function getConsoleMessageFromMetadata(metadata) {
|
||||||
|
return Buffer.from(metadata[CONSOLE_MESSAGE_KEY], 'base64').toString('utf-8')
|
||||||
|
}
|
||||||
|
|
||||||
async function makeFile(file, extension = '.scad', makeHash) {
|
async function makeFile(file, extension = '.scad', makeHash) {
|
||||||
const tempFile = 'a' + makeHash() // 'a' ensure nothing funny happens if it start with a bad character like "-", maybe I should pick a safer id generator :shrug:
|
const tempFile = 'a' + makeHash() // 'a' ensure nothing funny happens if it start with a bad character like "-", maybe I should pick a safer id generator :shrug:
|
||||||
@@ -35,7 +48,101 @@ async function runCommand(command, timeout = 5000) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeHash(script) {
|
||||||
|
return createHash('sha256').update(script).digest('hex')
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkIfAlreadyExists(params, s3) {
|
||||||
|
try {
|
||||||
|
const objectHead = await s3.headObject(params).promise()
|
||||||
|
const consoleMessage = getConsoleMessageFromMetadata(objectHead.Metadata)
|
||||||
|
console.log('consoleMessage', consoleMessage)
|
||||||
|
return { isAlreadyInBucket: true, consoleMessage }
|
||||||
|
} catch (e) {
|
||||||
|
console.log("couldn't find it", e)
|
||||||
|
return { isAlreadyInBucket: false }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getObjectUrl(params, s3) {
|
||||||
|
const HALF_HOUR = 1800
|
||||||
|
return s3.getSignedUrl('getObject', {
|
||||||
|
...params,
|
||||||
|
Expires: HALF_HOUR,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function loggerWrap(handler) {
|
||||||
|
You can create a signed url for a resource that doesn't exist (I guess aws assume you know if it does or not) You can create a signed url for a resource that doesn't exist (I guess aws assume you know if it does or not)
so we have to fetch the object's metadata/headObject to see if it exists, and we can grab the console message from metadata while we're at it.
|
|||||||
|
return (req, _context, callback) => {
|
||||||
|
try {
|
||||||
|
return handler(req, _context, callback)
|
||||||
|
} catch (e) {
|
||||||
|
console.log('error in handler', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function storeAssetAndReturnUrl({
|
||||||
|
error,
|
||||||
|
callback,
|
||||||
|
fullPath,
|
||||||
|
consoleMessage,
|
||||||
|
key,
|
||||||
|
s3,
|
||||||
|
params,
|
||||||
|
}) {
|
||||||
|
if (error) {
|
||||||
|
const response = {
|
||||||
|
statusCode: 400,
|
||||||
|
body: JSON.stringify({ error, fullPath }),
|
||||||
|
}
|
||||||
|
callback(null, response)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
console.log(`got result in route: ${consoleMessage}, file is: ${fullPath}`)
|
||||||
|
const { readFile } = require('fs/promises')
|
||||||
|
let buffer
|
||||||
|
|
||||||
|
After a part is successful generated the following steps is common to both OpenSCAD and CadQuery so threw it in a function, should probably be cleaned up a little. After a part is successful generated the following steps is common to both OpenSCAD and CadQuery so threw it in a function, should probably be cleaned up a little.
|
|||||||
|
try {
|
||||||
|
buffer = await readFile(fullPath)
|
||||||
|
} catch (e) {
|
||||||
|
console.log('read file error', e)
|
||||||
|
const response = {
|
||||||
|
statusCode: 400,
|
||||||
|
body: JSON.stringify({ error: consoleMessage, fullPath }),
|
||||||
|
}
|
||||||
|
callback(null, response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const storedRender = await s3
|
||||||
|
.putObject({
|
||||||
|
Bucket: process.env.BUCKET,
|
||||||
|
Key: key,
|
||||||
|
Body: buffer,
|
||||||
|
Metadata: putConsoleMessageInMetadata(consoleMessage),
|
||||||
|
})
|
||||||
|
.promise()
|
||||||
|
console.log('stored object', storedRender)
|
||||||
|
const url = getObjectUrl(params, s3)
|
||||||
|
console.log('url', url)
|
||||||
|
const response = {
|
||||||
|
statusCode: 200,
|
||||||
|
body: JSON.stringify({
|
||||||
|
url,
|
||||||
|
consoleMessage,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
callback(null, response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
runCommand,
|
runCommand,
|
||||||
makeFile,
|
makeFile,
|
||||||
|
makeHash,
|
||||||
|
checkIfAlreadyExists,
|
||||||
|
getObjectUrl,
|
||||||
|
loggerWrap,
|
||||||
|
storeAssetAndReturnUrl,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,95 +1,88 @@
|
|||||||
const { runScad, stlExport } = require('./runScad')
|
const { runScad } = require('./runScad')
|
||||||
const middy = require('middy')
|
const middy = require('middy')
|
||||||
const { cors } = require('middy/middlewares')
|
const { cors } = require('middy/middlewares')
|
||||||
|
const AWS = require('aws-sdk')
|
||||||
|
const {
|
||||||
|
makeHash,
|
||||||
|
checkIfAlreadyExists,
|
||||||
|
getObjectUrl,
|
||||||
|
loggerWrap,
|
||||||
|
storeAssetAndReturnUrl,
|
||||||
|
} = require('../common/utils')
|
||||||
|
|
||||||
const health = async () => {
|
const s3 = new AWS.S3()
|
||||||
console.log('Health endpoint')
|
|
||||||
return {
|
|
||||||
statusCode: 200,
|
|
||||||
body: 'ok',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// cors true does not seem to work in serverless.yml, perhaps docker lambdas aren't covered by that config
|
|
||||||
// special lambda just for responding to options requests
|
|
||||||
const preflightOptions = (req, _context, callback) => {
|
|
||||||
const response = {
|
|
||||||
statusCode: 204,
|
|
||||||
headers: {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Access-Control-Allow-Methods': 'POST',
|
|
||||||
'Access-Control-Allow-Headers': '*',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
callback(null, response)
|
|
||||||
}
|
|
||||||
|
|
||||||
const preview = async (req, _context, callback) => {
|
const preview = async (req, _context, callback) => {
|
||||||
_context.callbackWaitsForEmptyEventLoop = false
|
_context.callbackWaitsForEmptyEventLoop = false
|
||||||
const eventBody = Buffer.from(req.body, 'base64').toString('ascii')
|
const eventBody = req.body
|
||||||
console.log(eventBody, 'eventBody')
|
console.log('eventBody', eventBody)
|
||||||
const { file, settings } = JSON.parse(eventBody)
|
const key = `${makeHash(eventBody)}.png`
|
||||||
const { error, result, tempFile } = await runScad({ file, settings })
|
console.log('key', key)
|
||||||
if (error) {
|
|
||||||
const response = {
|
const params = {
|
||||||
statusCode: 400,
|
Bucket: process.env.BUCKET,
|
||||||
body: JSON.stringify({ error, tempFile }),
|
Key: key,
|
||||||
}
|
}
|
||||||
callback(null, response)
|
const previousAsset = await checkIfAlreadyExists(params, s3)
|
||||||
} else {
|
if (previousAsset.isAlreadyInBucket) {
|
||||||
console.log(`got result in route: ${result}, file is: ${tempFile}`)
|
console.log('already in bucket')
|
||||||
const fs = require('fs')
|
|
||||||
const image = fs.readFileSync(`/tmp/${tempFile}/output.png`, {
|
|
||||||
encoding: 'base64',
|
|
||||||
})
|
|
||||||
console.log(image, 'encoded image')
|
|
||||||
const response = {
|
const response = {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
imageBase64: image,
|
url: getObjectUrl(params, s3),
|
||||||
result,
|
consoleMessage: previousAsset.consoleMessage,
|
||||||
tempFile,
|
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
callback(null, response)
|
callback(null, response)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { file, settings } = JSON.parse(eventBody)
|
||||||
|
const { error, consoleMessage, fullPath } = await runScad({ file, settings })
|
||||||
|
await storeAssetAndReturnUrl({
|
||||||
|
error,
|
||||||
|
callback,
|
||||||
|
fullPath,
|
||||||
|
consoleMessage,
|
||||||
|
key,
|
||||||
|
s3,
|
||||||
|
params,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const stl = async (req, _context, callback) => {
|
// const stl = async (req, _context, callback) => {
|
||||||
_context.callbackWaitsForEmptyEventLoop = false
|
// _context.callbackWaitsForEmptyEventLoop = false
|
||||||
const eventBody = Buffer.from(req.body, 'base64').toString('ascii')
|
// const eventBody = Buffer.from(req.body, 'base64').toString('ascii')
|
||||||
console.log(eventBody, 'eventBody')
|
// console.log(eventBody, 'eventBody')
|
||||||
const { file } = JSON.parse(eventBody)
|
// const { file } = JSON.parse(eventBody)
|
||||||
const { error, result, tempFile } = await stlExport({ file })
|
// const { error, result, tempFile } = await stlExport({ file })
|
||||||
if (error) {
|
// if (error) {
|
||||||
const response = {
|
// const response = {
|
||||||
statusCode: 400,
|
// statusCode: 400,
|
||||||
body: { error, tempFile },
|
// body: { error, tempFile },
|
||||||
}
|
// }
|
||||||
callback(null, response)
|
// callback(null, response)
|
||||||
} else {
|
// } else {
|
||||||
console.log(`got result in route: ${result}, file is: ${tempFile}`)
|
// console.log(`got result in route: ${result}, file is: ${tempFile}`)
|
||||||
const fs = require('fs')
|
// const fs = require('fs')
|
||||||
const stl = fs.readFileSync(`/tmp/${tempFile}/output.stl`, {
|
// const stl = fs.readFileSync(`/tmp/${tempFile}/output.stl`, {
|
||||||
encoding: 'base64',
|
// encoding: 'base64',
|
||||||
})
|
// })
|
||||||
console.log('encoded stl', stl)
|
// console.log('encoded stl', stl)
|
||||||
const response = {
|
// const response = {
|
||||||
statusCode: 200,
|
// statusCode: 200,
|
||||||
headers: {
|
// headers: {
|
||||||
'content-type': 'application/stl',
|
// 'content-type': 'application/stl',
|
||||||
},
|
// },
|
||||||
body: stl,
|
// body: stl,
|
||||||
isBase64Encoded: true,
|
// isBase64Encoded: true,
|
||||||
}
|
// }
|
||||||
console.log('callback fired')
|
// console.log('callback fired')
|
||||||
callback(null, response)
|
// callback(null, response)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
health: middy(health).use(cors()),
|
// stl: middy(stl).use(cors()),
|
||||||
stl: middy(stl).use(cors()),
|
preview: middy(loggerWrap(preview)).use(cors()),
|
||||||
preview: middy(preview).use(cors()),
|
|
||||||
preflightOptions,
|
|
||||||
}
|
}
|
||||||
|
|||||||
2247
app/api/src/docker/openscad/package-lock.json
generated
Normal file
@@ -6,6 +6,7 @@
|
|||||||
"author": "Kurt Hutten <kurt@kurthutten.com>",
|
"author": "Kurt Hutten <kurt@kurthutten.com>",
|
||||||
"license": "",
|
"license": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"aws-sdk": "^2.907.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"middy": "^0.36.0",
|
"middy": "^0.36.0",
|
||||||
"nanoid": "^3.1.20"
|
"nanoid": "^3.1.20"
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
const { makeFile, runCommand } = require('../common/utils')
|
const { makeFile, runCommand } = require('../common/utils')
|
||||||
const { nanoid } = require('nanoid')
|
const { nanoid } = require('nanoid')
|
||||||
|
|
||||||
|
/** Removes our generated/hash filename with just "main.scad", so that it's a nice message in the IDE */
|
||||||
|
const cleanOpenScadError = (error) =>
|
||||||
|
error.replace(/["|']\/tmp\/.+\/main.scad["|']/g, "'main.scad'")
|
||||||
|
|
||||||
module.exports.runScad = async ({
|
module.exports.runScad = async ({
|
||||||
file,
|
file,
|
||||||
settings: {
|
settings: {
|
||||||
@@ -16,14 +20,16 @@ module.exports.runScad = async ({
|
|||||||
const { x: rx, y: ry, z: rz } = rotation
|
const { x: rx, y: ry, z: rz } = rotation
|
||||||
const { x: px, y: py, z: pz } = position
|
const { x: px, y: py, z: pz } = position
|
||||||
const cameraArg = `--camera=${px},${py},${pz},${rx},${ry},${rz},${dist}`
|
const cameraArg = `--camera=${px},${py},${pz},${rx},${ry},${rz},${dist}`
|
||||||
const command = `xvfb-run --auto-servernum --server-args "-screen 0 1024x768x24" openscad -o /tmp/${tempFile}/output.png ${cameraArg} --imgsize=${x},${y} --colorscheme DeepOcean /tmp/${tempFile}/main.scad`
|
const fullPath = `/tmp/${tempFile}/output.png`
|
||||||
|
const command = `xvfb-run --auto-servernum --server-args "-screen 0 1024x768x24" openscad -o ${fullPath} ${cameraArg} --imgsize=${x},${y} --colorscheme DeepOcean /tmp/${tempFile}/main.scad`
|
||||||
console.log('command', command)
|
console.log('command', command)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await runCommand(command, 15000)
|
const consoleMessage = await runCommand(command, 15000)
|
||||||
return { result, tempFile }
|
return { consoleMessage, fullPath }
|
||||||
} catch (error) {
|
} catch (dirtyError) {
|
||||||
return { error, tempFile }
|
const error = cleanOpenScadError(dirtyError)
|
||||||
|
return { error }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,386 +0,0 @@
|
|||||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
||||||
# yarn lockfile v1
|
|
||||||
|
|
||||||
|
|
||||||
accepts@~1.3.7:
|
|
||||||
version "1.3.7"
|
|
||||||
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd"
|
|
||||||
integrity sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==
|
|
||||||
dependencies:
|
|
||||||
mime-types "~2.1.24"
|
|
||||||
negotiator "0.6.2"
|
|
||||||
|
|
||||||
array-flatten@1.1.1:
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2"
|
|
||||||
integrity sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=
|
|
||||||
|
|
||||||
body-parser@1.19.0:
|
|
||||||
version "1.19.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a"
|
|
||||||
integrity sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==
|
|
||||||
dependencies:
|
|
||||||
bytes "3.1.0"
|
|
||||||
content-type "~1.0.4"
|
|
||||||
debug "2.6.9"
|
|
||||||
depd "~1.1.2"
|
|
||||||
http-errors "1.7.2"
|
|
||||||
iconv-lite "0.4.24"
|
|
||||||
on-finished "~2.3.0"
|
|
||||||
qs "6.7.0"
|
|
||||||
raw-body "2.4.0"
|
|
||||||
type-is "~1.6.17"
|
|
||||||
|
|
||||||
bytes@3.1.0:
|
|
||||||
version "3.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6"
|
|
||||||
integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==
|
|
||||||
|
|
||||||
content-disposition@0.5.3:
|
|
||||||
version "0.5.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd"
|
|
||||||
integrity sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==
|
|
||||||
dependencies:
|
|
||||||
safe-buffer "5.1.2"
|
|
||||||
|
|
||||||
content-type@~1.0.4:
|
|
||||||
version "1.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b"
|
|
||||||
integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==
|
|
||||||
|
|
||||||
cookie-signature@1.0.6:
|
|
||||||
version "1.0.6"
|
|
||||||
resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c"
|
|
||||||
integrity sha1-4wOogrNCzD7oylE6eZmXNNqzriw=
|
|
||||||
|
|
||||||
cookie@0.4.0:
|
|
||||||
version "0.4.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba"
|
|
||||||
integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==
|
|
||||||
|
|
||||||
cors@^2.8.5:
|
|
||||||
version "2.8.5"
|
|
||||||
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
|
|
||||||
integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==
|
|
||||||
dependencies:
|
|
||||||
object-assign "^4"
|
|
||||||
vary "^1"
|
|
||||||
|
|
||||||
debug@2.6.9:
|
|
||||||
version "2.6.9"
|
|
||||||
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
|
|
||||||
integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==
|
|
||||||
dependencies:
|
|
||||||
ms "2.0.0"
|
|
||||||
|
|
||||||
depd@~1.1.2:
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
|
|
||||||
integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=
|
|
||||||
|
|
||||||
destroy@~1.0.4:
|
|
||||||
version "1.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80"
|
|
||||||
integrity sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=
|
|
||||||
|
|
||||||
ee-first@1.1.1:
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
|
|
||||||
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
|
|
||||||
|
|
||||||
encodeurl@~1.0.2:
|
|
||||||
version "1.0.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59"
|
|
||||||
integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=
|
|
||||||
|
|
||||||
escape-html@~1.0.3:
|
|
||||||
version "1.0.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"
|
|
||||||
integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=
|
|
||||||
|
|
||||||
etag@~1.8.1:
|
|
||||||
version "1.8.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887"
|
|
||||||
integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=
|
|
||||||
|
|
||||||
express@^4.17.1:
|
|
||||||
version "4.17.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134"
|
|
||||||
integrity sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==
|
|
||||||
dependencies:
|
|
||||||
accepts "~1.3.7"
|
|
||||||
array-flatten "1.1.1"
|
|
||||||
body-parser "1.19.0"
|
|
||||||
content-disposition "0.5.3"
|
|
||||||
content-type "~1.0.4"
|
|
||||||
cookie "0.4.0"
|
|
||||||
cookie-signature "1.0.6"
|
|
||||||
debug "2.6.9"
|
|
||||||
depd "~1.1.2"
|
|
||||||
encodeurl "~1.0.2"
|
|
||||||
escape-html "~1.0.3"
|
|
||||||
etag "~1.8.1"
|
|
||||||
finalhandler "~1.1.2"
|
|
||||||
fresh "0.5.2"
|
|
||||||
merge-descriptors "1.0.1"
|
|
||||||
methods "~1.1.2"
|
|
||||||
on-finished "~2.3.0"
|
|
||||||
parseurl "~1.3.3"
|
|
||||||
path-to-regexp "0.1.7"
|
|
||||||
proxy-addr "~2.0.5"
|
|
||||||
qs "6.7.0"
|
|
||||||
range-parser "~1.2.1"
|
|
||||||
safe-buffer "5.1.2"
|
|
||||||
send "0.17.1"
|
|
||||||
serve-static "1.14.1"
|
|
||||||
setprototypeof "1.1.1"
|
|
||||||
statuses "~1.5.0"
|
|
||||||
type-is "~1.6.18"
|
|
||||||
utils-merge "1.0.1"
|
|
||||||
vary "~1.1.2"
|
|
||||||
|
|
||||||
finalhandler@~1.1.2:
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d"
|
|
||||||
integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==
|
|
||||||
dependencies:
|
|
||||||
debug "2.6.9"
|
|
||||||
encodeurl "~1.0.2"
|
|
||||||
escape-html "~1.0.3"
|
|
||||||
on-finished "~2.3.0"
|
|
||||||
parseurl "~1.3.3"
|
|
||||||
statuses "~1.5.0"
|
|
||||||
unpipe "~1.0.0"
|
|
||||||
|
|
||||||
forwarded@~0.1.2:
|
|
||||||
version "0.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84"
|
|
||||||
integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=
|
|
||||||
|
|
||||||
fresh@0.5.2:
|
|
||||||
version "0.5.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7"
|
|
||||||
integrity sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=
|
|
||||||
|
|
||||||
http-errors@1.7.2:
|
|
||||||
version "1.7.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.2.tgz#4f5029cf13239f31036e5b2e55292bcfbcc85c8f"
|
|
||||||
integrity sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==
|
|
||||||
dependencies:
|
|
||||||
depd "~1.1.2"
|
|
||||||
inherits "2.0.3"
|
|
||||||
setprototypeof "1.1.1"
|
|
||||||
statuses ">= 1.5.0 < 2"
|
|
||||||
toidentifier "1.0.0"
|
|
||||||
|
|
||||||
http-errors@~1.7.2:
|
|
||||||
version "1.7.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.3.tgz#6c619e4f9c60308c38519498c14fbb10aacebb06"
|
|
||||||
integrity sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==
|
|
||||||
dependencies:
|
|
||||||
depd "~1.1.2"
|
|
||||||
inherits "2.0.4"
|
|
||||||
setprototypeof "1.1.1"
|
|
||||||
statuses ">= 1.5.0 < 2"
|
|
||||||
toidentifier "1.0.0"
|
|
||||||
|
|
||||||
iconv-lite@0.4.24:
|
|
||||||
version "0.4.24"
|
|
||||||
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"
|
|
||||||
integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==
|
|
||||||
dependencies:
|
|
||||||
safer-buffer ">= 2.1.2 < 3"
|
|
||||||
|
|
||||||
inherits@2.0.3:
|
|
||||||
version "2.0.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
|
||||||
integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
|
|
||||||
|
|
||||||
inherits@2.0.4:
|
|
||||||
version "2.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
|
|
||||||
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
|
|
||||||
|
|
||||||
ipaddr.js@1.9.1:
|
|
||||||
version "1.9.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3"
|
|
||||||
integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==
|
|
||||||
|
|
||||||
media-typer@0.3.0:
|
|
||||||
version "0.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
|
|
||||||
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=
|
|
||||||
|
|
||||||
merge-descriptors@1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61"
|
|
||||||
integrity sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=
|
|
||||||
|
|
||||||
methods@~1.1.2:
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
|
|
||||||
integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=
|
|
||||||
|
|
||||||
mime-db@1.46.0:
|
|
||||||
version "1.46.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.46.0.tgz#6267748a7f799594de3cbc8cde91def349661cee"
|
|
||||||
integrity sha512-svXaP8UQRZ5K7or+ZmfNhg2xX3yKDMUzqadsSqi4NCH/KomcH75MAMYAGVlvXn4+b/xOPhS3I2uHKRUzvjY7BQ==
|
|
||||||
|
|
||||||
mime-types@~2.1.24:
|
|
||||||
version "2.1.29"
|
|
||||||
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.29.tgz#1d4ab77da64b91f5f72489df29236563754bb1b2"
|
|
||||||
integrity sha512-Y/jMt/S5sR9OaqteJtslsFZKWOIIqMACsJSiHghlCAyhf7jfVYjKBmLiX8OgpWeW+fjJ2b+Az69aPFPkUOY6xQ==
|
|
||||||
dependencies:
|
|
||||||
mime-db "1.46.0"
|
|
||||||
|
|
||||||
mime@1.6.0:
|
|
||||||
version "1.6.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
|
|
||||||
integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==
|
|
||||||
|
|
||||||
ms@2.0.0:
|
|
||||||
version "2.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
|
|
||||||
integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=
|
|
||||||
|
|
||||||
ms@2.1.1:
|
|
||||||
version "2.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
|
|
||||||
integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==
|
|
||||||
|
|
||||||
nanoid@^3.1.20:
|
|
||||||
version "3.1.20"
|
|
||||||
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.20.tgz#badc263c6b1dcf14b71efaa85f6ab4c1d6cfc788"
|
|
||||||
integrity sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==
|
|
||||||
|
|
||||||
negotiator@0.6.2:
|
|
||||||
version "0.6.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb"
|
|
||||||
integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==
|
|
||||||
|
|
||||||
object-assign@^4:
|
|
||||||
version "4.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
|
||||||
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
|
|
||||||
|
|
||||||
on-finished@~2.3.0:
|
|
||||||
version "2.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947"
|
|
||||||
integrity sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=
|
|
||||||
dependencies:
|
|
||||||
ee-first "1.1.1"
|
|
||||||
|
|
||||||
parseurl@~1.3.3:
|
|
||||||
version "1.3.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4"
|
|
||||||
integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==
|
|
||||||
|
|
||||||
path-to-regexp@0.1.7:
|
|
||||||
version "0.1.7"
|
|
||||||
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
|
|
||||||
integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=
|
|
||||||
|
|
||||||
proxy-addr@~2.0.5:
|
|
||||||
version "2.0.6"
|
|
||||||
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.6.tgz#fdc2336505447d3f2f2c638ed272caf614bbb2bf"
|
|
||||||
integrity sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==
|
|
||||||
dependencies:
|
|
||||||
forwarded "~0.1.2"
|
|
||||||
ipaddr.js "1.9.1"
|
|
||||||
|
|
||||||
qs@6.7.0:
|
|
||||||
version "6.7.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
|
|
||||||
integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==
|
|
||||||
|
|
||||||
range-parser@~1.2.1:
|
|
||||||
version "1.2.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031"
|
|
||||||
integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==
|
|
||||||
|
|
||||||
raw-body@2.4.0:
|
|
||||||
version "2.4.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.0.tgz#a1ce6fb9c9bc356ca52e89256ab59059e13d0332"
|
|
||||||
integrity sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==
|
|
||||||
dependencies:
|
|
||||||
bytes "3.1.0"
|
|
||||||
http-errors "1.7.2"
|
|
||||||
iconv-lite "0.4.24"
|
|
||||||
unpipe "1.0.0"
|
|
||||||
|
|
||||||
safe-buffer@5.1.2:
|
|
||||||
version "5.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
|
|
||||||
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
|
|
||||||
|
|
||||||
"safer-buffer@>= 2.1.2 < 3":
|
|
||||||
version "2.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
|
|
||||||
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
|
|
||||||
|
|
||||||
send@0.17.1:
|
|
||||||
version "0.17.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8"
|
|
||||||
integrity sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==
|
|
||||||
dependencies:
|
|
||||||
debug "2.6.9"
|
|
||||||
depd "~1.1.2"
|
|
||||||
destroy "~1.0.4"
|
|
||||||
encodeurl "~1.0.2"
|
|
||||||
escape-html "~1.0.3"
|
|
||||||
etag "~1.8.1"
|
|
||||||
fresh "0.5.2"
|
|
||||||
http-errors "~1.7.2"
|
|
||||||
mime "1.6.0"
|
|
||||||
ms "2.1.1"
|
|
||||||
on-finished "~2.3.0"
|
|
||||||
range-parser "~1.2.1"
|
|
||||||
statuses "~1.5.0"
|
|
||||||
|
|
||||||
serve-static@1.14.1:
|
|
||||||
version "1.14.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.1.tgz#666e636dc4f010f7ef29970a88a674320898b2f9"
|
|
||||||
integrity sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==
|
|
||||||
dependencies:
|
|
||||||
encodeurl "~1.0.2"
|
|
||||||
escape-html "~1.0.3"
|
|
||||||
parseurl "~1.3.3"
|
|
||||||
send "0.17.1"
|
|
||||||
|
|
||||||
setprototypeof@1.1.1:
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683"
|
|
||||||
integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==
|
|
||||||
|
|
||||||
"statuses@>= 1.5.0 < 2", statuses@~1.5.0:
|
|
||||||
version "1.5.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
|
|
||||||
integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=
|
|
||||||
|
|
||||||
toidentifier@1.0.0:
|
|
||||||
version "1.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"
|
|
||||||
integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
|
|
||||||
|
|
||||||
type-is@~1.6.17, type-is@~1.6.18:
|
|
||||||
version "1.6.18"
|
|
||||||
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131"
|
|
||||||
integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==
|
|
||||||
dependencies:
|
|
||||||
media-typer "0.3.0"
|
|
||||||
mime-types "~2.1.24"
|
|
||||||
|
|
||||||
unpipe@1.0.0, unpipe@~1.0.0:
|
|
||||||
version "1.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
|
|
||||||
integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=
|
|
||||||
|
|
||||||
utils-merge@1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
|
|
||||||
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
|
|
||||||
|
|
||||||
vary@^1, vary@~1.1.2:
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
|
|
||||||
integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=
|
|
||||||
@@ -24,60 +24,30 @@ provider:
|
|||||||
file: ./cadquery/Dockerfile
|
file: ./cadquery/Dockerfile
|
||||||
apiGateway:
|
apiGateway:
|
||||||
metrics: true
|
metrics: true
|
||||||
binaryMediaTypes:
|
|
||||||
# we need to allow binary types to be able to send back images and stls, but it would be better to be more specific
|
|
||||||
# ie image/png etc. as */* treats everything as binary including the json body as the input the lambdas
|
|
||||||
# which mean we need to decode the input bode from base64, but the images break with anything other than */* :(
|
|
||||||
- '*/*'
|
|
||||||
|
|
||||||
# you can overwrite defaults here
|
# you can overwrite defaults here
|
||||||
# stage: dev
|
# stage: dev
|
||||||
# region: us-east-1
|
# region: us-east-1
|
||||||
|
|
||||||
|
Removing this magically fixed CORS issues I was having as I mentioned in a previous comment. Removing this magically fixed CORS issues I was having as I mentioned in a previous comment.
|
|||||||
# you can add statements to the Lambda function's IAM Role here
|
# you can add statements to the Lambda function's IAM Role here
|
||||||
# iamRoleStatements:
|
iam:
|
||||||
# - Effect: "Allow"
|
role:
|
||||||
# Action:
|
statements:
|
||||||
# - "s3:ListBucket"
|
- Effect: "Allow"
|
||||||
# Resource: { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "ServerlessDeploymentBucket" } ] ] }
|
Action:
|
||||||
# - Effect: "Allow"
|
- "s3:GetObject"
|
||||||
# Action:
|
Resource: "arn:aws:s3:::cad-preview-bucket-prod-001/*"
|
||||||
# - "s3:PutObject"
|
- Effect: "Allow"
|
||||||
# Resource:
|
Action:
|
||||||
# Fn::Join:
|
- "s3:PutObject"
|
||||||
# - ""
|
Resource: "arn:aws:s3:::cad-preview-bucket-prod-001/*"
|
||||||
# - - "arn:aws:s3:::"
|
# Dev bucket is cad-preview-bucket-dev-001/*"
|
||||||
# - "Ref" : "ServerlessDeploymentBucket"
|
|
||||||
# - "/*"
|
|
||||||
|
|
||||||
# you can define service wide environment variables here
|
# you can define service wide environment variables here
|
||||||
# environment:
|
# environment:
|
||||||
# variable1: value1
|
# variable1: value1
|
||||||
|
|
||||||
functions:
|
functions:
|
||||||
# see preflightoptions comment in openscad.js
|
|
||||||
preflightopenscadpreview:
|
|
||||||
image:
|
|
||||||
name: openscadimage
|
|
||||||
command:
|
|
||||||
- openscad.preflightOptions
|
|
||||||
entryPoint:
|
|
||||||
- '/entrypoint.sh'
|
|
||||||
events:
|
|
||||||
- http:
|
|
||||||
path: openscad/preview
|
|
||||||
method: options
|
|
||||||
preflightopenscadstl:
|
|
||||||
image:
|
|
||||||
name: openscadimage
|
|
||||||
command:
|
|
||||||
- openscad.preflightOptions
|
|
||||||
entryPoint:
|
|
||||||
- '/entrypoint.sh'
|
|
||||||
events:
|
|
||||||
- http:
|
|
||||||
path: openscad/stl
|
|
||||||
method: options
|
|
||||||
openscadpreview:
|
openscadpreview:
|
||||||
image:
|
image:
|
||||||
name: openscadimage
|
name: openscadimage
|
||||||
@@ -89,31 +59,22 @@ functions:
|
|||||||
- http:
|
- http:
|
||||||
path: openscad/preview
|
path: openscad/preview
|
||||||
method: post
|
method: post
|
||||||
timeout: 15
|
cors: true
|
||||||
openscadstl:
|
timeout: 25
|
||||||
image:
|
environment:
|
||||||
name: openscadimage
|
BUCKET: cad-preview-bucket-prod-001
|
||||||
command:
|
# openscadstl:
|
||||||
- openscad.stl
|
# image:
|
||||||
entryPoint:
|
# name: openscadimage
|
||||||
- '/entrypoint.sh'
|
# command:
|
||||||
events:
|
# - openscad.stl
|
||||||
- http:
|
# entryPoint:
|
||||||
path: openscad/stl
|
# - '/entrypoint.sh'
|
||||||
method: post
|
# events:
|
||||||
timeout: 30
|
# - http:
|
||||||
|
# path: openscad/stl
|
||||||
preflightcadquerystl:
|
# method: post
|
||||||
image:
|
# timeout: 30
|
||||||
name: cadqueryimage
|
|
||||||
command:
|
|
||||||
- cadquery.preflightOptions
|
|
||||||
entryPoint:
|
|
||||||
- '/entrypoint.sh'
|
|
||||||
events:
|
|
||||||
- http:
|
|
||||||
path: cadquery/stl
|
|
||||||
method: options
|
|
||||||
cadquerystl:
|
cadquerystl:
|
||||||
image:
|
image:
|
||||||
name: cadqueryimage
|
name: cadqueryimage
|
||||||
@@ -125,7 +86,10 @@ functions:
|
|||||||
- http:
|
- http:
|
||||||
path: cadquery/stl
|
path: cadquery/stl
|
||||||
method: post
|
method: post
|
||||||
|
cors: true
|
||||||
timeout: 30
|
timeout: 30
|
||||||
|
environment:
|
||||||
|
BUCKET: cad-preview-bucket-prod-001
|
||||||
# The following are a few example events you can configure
|
# The following are a few example events you can configure
|
||||||
# NOTE: Please make sure to change your handler code to work with those events
|
# NOTE: Please make sure to change your handler code to work with those events
|
||||||
# Check the event documentation for details
|
# Check the event documentation for details
|
||||||
|
|||||||
@@ -14,19 +14,27 @@ import { requestRender } from 'src/helpers/hooks/useIdeState'
|
|||||||
|
|
||||||
extend({ OrbitControls })
|
extend({ OrbitControls })
|
||||||
|
|
||||||
function Asset({ stlData }) {
|
function Asset({ url, resetLoading, setLoading }) {
|
||||||
const [loadedGeometry, setLoadedGeometry] = useState()
|
const [loadedGeometry, setLoadedGeometry] = useState()
|
||||||
const mesh = useRef()
|
const mesh = useRef()
|
||||||
const ref = useUpdate((geometry) => {
|
const ref = useUpdate((geometry) => {
|
||||||
geometry.attributes = loadedGeometry.attributes
|
geometry.attributes = loadedGeometry.attributes
|
||||||
})
|
})
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (stlData) {
|
if (url) {
|
||||||
const decoded = atob(stlData)
|
|
||||||
const loader = new STLLoader()
|
const loader = new STLLoader()
|
||||||
setLoadedGeometry(loader.parse(decoded))
|
setLoading()
|
||||||
|
loader.load(
|
||||||
|
url,
|
||||||
|
(geometry) => {
|
||||||
|
setLoadedGeometry(geometry)
|
||||||
|
resetLoading()
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
resetLoading
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}, [stlData])
|
}, [url])
|
||||||
if (!loadedGeometry) return null
|
if (!loadedGeometry) return null
|
||||||
return (
|
return (
|
||||||
|
Because the asset is not being returned directly, but instead a URL to it, I now need to make sure the loading animation stays on while the asset loads, especially for the stls as they can be large. Because the asset is not being returned directly, but instead a URL to it, I now need to make sure the loading animation stays on while the asset loads, especially for the stls as they can be large.
|
|||||||
<mesh ref={mesh} scale={[1, 1, 1]}>
|
<mesh ref={mesh} scale={[1, 1, 1]}>
|
||||||
@@ -150,11 +158,11 @@ const IdeViewer = () => {
|
|||||||
const [isDragging, setIsDragging] = useState(false)
|
const [isDragging, setIsDragging] = useState(false)
|
||||||
const [image, setImage] = useState()
|
const [image, setImage] = useState()
|
||||||
|
|
||||||
|
const resetLoading = () => thunkDispatch({ type: 'resetLoading' })
|
||||||
|
const setLoading = () => thunkDispatch({ type: 'setLoading' })
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setImage(
|
setImage(state.objectData?.type === 'png' && state.objectData?.data)
|
||||||
state.objectData?.type === 'png' &&
|
|
||||||
'data:image/png;base64,' + state.objectData?.data
|
|
||||||
)
|
|
||||||
setIsDragging(false)
|
setIsDragging(false)
|
||||||
}, [state.objectData?.type, state.objectData?.data])
|
}, [state.objectData?.type, state.objectData?.data])
|
||||||
|
|
||||||
@@ -229,9 +237,9 @@ const IdeViewer = () => {
|
|||||||
)}
|
)}
|
||||||
{state.ideType === 'cadQuery' && (
|
{state.ideType === 'cadQuery' && (
|
||||||
<Asset
|
<Asset
|
||||||
stlData={
|
url={state.objectData?.type === 'stl' && state.objectData?.data}
|
||||||
state.objectData?.type === 'stl' && state.objectData?.data
|
resetLoading={resetLoading}
|
||||||
}
|
setLoading={setLoading}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Canvas>
|
</Canvas>
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ export const render = async ({ code }) => {
|
|||||||
status: 'healthy',
|
status: 'healthy',
|
||||||
objectData: {
|
objectData: {
|
||||||
type: 'stl',
|
type: 'stl',
|
||||||
data: data.imageBase64,
|
data: data.url,
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
type: 'message',
|
type: 'message',
|
||||||
message: data.result || 'Successful Render',
|
message: data.consoleMessage || 'Successful Render',
|
||||||
time: new Date(),
|
time: new Date(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
export const lambdaBaseURL =
|
export const lambdaBaseURL =
|
||||||
process.env.CAD_LAMBDA_BASE_URL ||
|
process.env.CAD_LAMBDA_BASE_URL ||
|
||||||
'https://wzab9s632b.execute-api.us-east-1.amazonaws.com/prod'
|
'https://2inlbple1b.execute-api.us-east-1.amazonaws.com/prod2'
|
||||||
|
|||||||
@@ -6,10 +6,25 @@ export const render = async ({ code, settings }) => {
|
|||||||
x: Math.round(settings.viewerSize?.width * pixelRatio),
|
x: Math.round(settings.viewerSize?.width * pixelRatio),
|
||||||
y: Math.round(settings.viewerSize?.height * pixelRatio),
|
y: Math.round(settings.viewerSize?.height * pixelRatio),
|
||||||
}
|
}
|
||||||
|
const round1dec = (number) => Math.round((number + Number.EPSILON) * 10) / 10
|
||||||
const body = JSON.stringify({
|
const body = JSON.stringify({
|
||||||
settings: {
|
settings: {
|
||||||
size,
|
size,
|
||||||
camera: settings.camera,
|
camera: {
|
||||||
|
// rounding to give our caching a chance to sometimes work
|
||||||
|
...settings.camera,
|
||||||
|
dist: round1dec(settings.camera.dist),
|
||||||
|
position: {
|
||||||
|
x: round1dec(settings.camera.position.x),
|
||||||
|
y: round1dec(settings.camera.position.y),
|
||||||
|
z: round1dec(settings.camera.position.z),
|
||||||
|
},
|
||||||
|
rotation: {
|
||||||
|
x: round1dec(settings.camera.rotation.x),
|
||||||
|
y: round1dec(settings.camera.rotation.y),
|
||||||
|
z: round1dec(settings.camera.rotation.z),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
file: code,
|
file: code,
|
||||||
})
|
})
|
||||||
@@ -44,11 +59,11 @@ export const render = async ({ code, settings }) => {
|
|||||||
status: 'healthy',
|
status: 'healthy',
|
||||||
objectData: {
|
objectData: {
|
||||||
type: 'png',
|
type: 'png',
|
||||||
data: data.imageBase64,
|
data: data.url,
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
type: 'message',
|
type: 'message',
|
||||||
message: data.result,
|
message: data.consoleMessage,
|
||||||
time: new Date(),
|
time: new Date(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ result = (cq.Workplane().circle(diam).extrude(20.0)
|
|||||||
.faces("<Z").workplane(invert=True).circle(0.8).cutBlind(12.0)
|
.faces("<Z").workplane(invert=True).circle(0.8).cutBlind(12.0)
|
||||||
.edges("%CIRCLE").chamfer(0.15))
|
.edges("%CIRCLE").chamfer(0.15))
|
||||||
|
|
||||||
# exporters.export(coupler, "/home/jwright/Downloads/coupler.stl", exporters.ExportTypes.STL)
|
|
||||||
|
|
||||||
show_object(result)
|
show_object(result)
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|||||||
This was me handling CORS preflight endpoints directly because I couldn't get the config working. Turns out it had something to do with binary media types which we don't need since we're not returning the asset directly now.