pouet
This commit is contained in:
parent
70d52c096d
commit
e41e81d162
@ -4,7 +4,7 @@ import node from "@astrojs/node";
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
// site: 'https://www.nasap3d.com',
|
||||
site: 'https://print.dzeio.com',
|
||||
integrations: [tailwind()],
|
||||
build: {
|
||||
assets: 'assets'
|
||||
@ -18,4 +18,4 @@ export default defineConfig({
|
||||
adapter: node({
|
||||
mode: "standalone"
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -1,54 +0,0 @@
|
||||
import { Response } from 'express'
|
||||
|
||||
/**
|
||||
* An error as of the RFC7807
|
||||
*
|
||||
* you MUST send the content-type `application/problem+json`
|
||||
*/
|
||||
export default interface HTTPError extends Record<string, any> {
|
||||
/**
|
||||
* A URI reference [RFC3986] that identifies the
|
||||
* problem type. This specification encourages that, when
|
||||
* dereferenced, it provide human-readable documentation for the
|
||||
* problem type (e.g., using HTML [W3C.REC-html5-20141028]). When
|
||||
* this member is not present, its value is assumed to be
|
||||
* "about:blank".
|
||||
*/
|
||||
title: string
|
||||
/**
|
||||
* A short, human-readable summary of the problem
|
||||
* type. It SHOULD NOT change from occurrence to occurrence of the
|
||||
* problem, except for purposes of localization (e.g., using
|
||||
* proactive content negotiation; see [RFC7231], Section 3.4).
|
||||
*/
|
||||
type?: string
|
||||
|
||||
/**
|
||||
* The HTTP status code ([RFC7231], Section 6)
|
||||
* generated by the origin server for this occurrence of the problem.
|
||||
*/
|
||||
status?: number
|
||||
|
||||
/**
|
||||
* A human-readable explanation specific to this
|
||||
* occurrence of the problem.
|
||||
*/
|
||||
detail?: string
|
||||
|
||||
|
||||
/**
|
||||
* A URI reference that identifies the specific
|
||||
* occurrence of the problem. It may or may not yield further
|
||||
* information if dereferenced.
|
||||
*/
|
||||
instance?: string
|
||||
}
|
||||
|
||||
export function createErrorResponse(res: Response, error: HTTPError) {
|
||||
res.status(error.status ?? 500)
|
||||
if (!error.type) {
|
||||
error.type = 'about:blank'
|
||||
}
|
||||
res.setHeader('Content-Type', 'application/problem+json')
|
||||
res.json(error)
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
import { objectMap, objectOmit } from '@dzeio/object-util'
|
||||
import URLManager from '@dzeio/url-manager'
|
||||
import type { APIRoute } from 'astro'
|
||||
import { exec as execSync } from 'child_process'
|
||||
import fs from 'fs/promises'
|
||||
import { evaluate } from 'mathjs'
|
||||
import { exec as execSync } from 'node:child_process'
|
||||
import fs from 'node:fs/promises'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path/posix'
|
||||
import { promisify } from 'node:util'
|
||||
@ -24,7 +24,7 @@ export const post: APIRoute = async ({ request }) => {
|
||||
const file = (Math.random() * 1000000).toFixed(0)
|
||||
console.log('started processing new request', file)
|
||||
await fs.mkdir(`${tmpDir}/files`, { recursive: true })
|
||||
|
||||
|
||||
const overrides = objectOmit(query, 'algo', 'config')
|
||||
const configName = query?.config ?? 'config'
|
||||
let config = `${import.meta.env.CONFIGS_PATH}/` + configName + '.ini'
|
||||
@ -39,7 +39,7 @@ export const post: APIRoute = async ({ request }) => {
|
||||
}
|
||||
const stlPath = `${tmpDir}/files/${file}.stl`
|
||||
const gcodePath = `${tmpDir}/files/${file}.gcode`
|
||||
|
||||
|
||||
// write file
|
||||
await fs.writeFile(stlPath, new Uint8Array(Buffer.from(await request.arrayBuffer())), {
|
||||
encoding: null
|
||||
@ -143,4 +143,4 @@ export const post: APIRoute = async ({ request }) => {
|
||||
gcode
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user