* Initial work to support curv * Correct the initial code file location * Preview and stl mvp working * Prepare changes for review and preview build * Run curv inside of /tmp When exporting an stl it writes temporary files which is not allowed when deployed to aws unless it's in temp. * Lock in specific curv commit for reproducible builds see: https://discord.com/channels/412182089279209474/886321278821216277/912507472441401385 * Add curv to backend schema * Frontend changes to accommodate curv deploy * Use vcount instead of vsize, as it's independant of geometry size, This is good for CadHub usecase where we don't know anything about the user's project * Final tweaks for deploy virtual screen size does matter,and curv is a little more memory hungry than the other functions * Format project Co-authored-by: lf94 <inbox@leefallat.ca> Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
const express = require('express')
|
|
var cors = require('cors')
|
|
const axios = require('axios')
|
|
const app = express()
|
|
const port = 8080
|
|
app.use(express.json())
|
|
app.use(cors())
|
|
|
|
const invocationURL = (port) =>
|
|
`http://localhost:${port}/2015-03-31/functions/function/invocations`
|
|
|
|
const makeRequest = (route, port) => [
|
|
route,
|
|
async (req, res) => {
|
|
console.log(`making post request to ${port}, ${route}`)
|
|
try {
|
|
const { data } = await axios.post(invocationURL(port), {
|
|
body: Buffer.from(JSON.stringify(req.body)).toString('base64'),
|
|
})
|
|
res.status(data.statusCode)
|
|
res.setHeader('Content-Type', 'application/javascript')
|
|
if (data.headers && data.headers['Content-Encoding'] === 'gzip') {
|
|
res.setHeader('Content-Encoding', 'gzip')
|
|
res.send(Buffer.from(data.body, 'base64'))
|
|
} else {
|
|
res.send(Buffer.from(data.body, 'base64'))
|
|
}
|
|
} catch (e) {
|
|
res.status(500)
|
|
res.send()
|
|
}
|
|
},
|
|
]
|
|
|
|
app.post(...makeRequest('/openscad/preview', 5052))
|
|
app.post(...makeRequest('/openscad/stl', 5053))
|
|
|
|
app.post(...makeRequest('/cadquery/stl', 5060))
|
|
|
|
app.post(...makeRequest('/curv/preview', 5070))
|
|
app.post(...makeRequest('/curv/stl', 5071))
|
|
|
|
app.listen(port, () => {
|
|
console.log(`Example app listening at http://localhost:${port}`)
|
|
})
|