diff --git a/package.json b/package.json index e816391..1e8fcd4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@bracketed/swiftcdn", "packageManager": "yarn@4.0.2", - "version": "3.1.3", + "version": "3.1.4", "repository": "https://github.com/ninjaninja140/templates-node-typescript", "author": { "name": "ninjaninja140", diff --git a/src/service.ts b/src/service.ts index 34aa8af..7c6c7c0 100644 --- a/src/service.ts +++ b/src/service.ts @@ -209,55 +209,24 @@ function initialize(Application_Port: string, Upload_Limit: number) { const file = Buffer.from(body.buffer, body.encoding); switch (body.type) { - case 'application': { - response.setHeader('Content-Disposition', `attachment; filename="${body.name}"`); - return response.status(200).send(file); - } case 'audio': { - const audio = ``; - const attachmentDetails = ``; - const css = - ':root { background-color: black; height: 100%; -moz-user-focus: ignore; } video { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; user-select: none; -moz-user-focus: normal; } video:focus { outline-style: none; } '; - - const html = `${attachmentDetails}${body.name}${audio}`; - - return response.status(200).send(html); + response.set('Content-Type', body.mime); + return response.status(200).end(file); } case 'video': { - const video = ``; - const attachmentDetails = ``; - const css = - ':root { background-color: black; height: 100%; -moz-user-focus: ignore; } video { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; user-select: none; -moz-user-focus: normal; } video:focus { outline-style: none; } '; - - const html = `${attachmentDetails}${body.name}${video}`; - - return response.status(200).send(html); + response.set('Content-Type', body.mime); + return response.status(200).end(file); } case 'text': { const text = file.toString('utf-8'); - const textcss = - 'pre { white-space: pre-wrap; word-wrap: break-word; -moz-control-character-visibility: visible; } .nowrap pre { white-space: pre; } html:not([dir]) pre { unicode-bidi: plaintext; } @-moz-document unobservable-document() { :root { color-scheme: light dark; } } @media (width: 0) or (height: 0) { :root { display: none; } }'; const attachmentDetails = ``; - const html = `${attachmentDetails}${body.name}
${text}
`; + const html = `${attachmentDetails}${body.name}
${text}
`; return response.status(200).send(html); } case 'image': { - const img = `${
-					body.name
-				}`; - const attachmentDetails = ``; - const css = - 'body { margin: 0; } @media not print { .fullZoomOut { cursor: zoom-out; } .fullZoomIn { cursor: zoom-in; } .shrinkToFit { cursor: zoom-in; } .overflowingVertical, .overflowingHorizontalOnly { cursor: zoom-out; } } .isInObjectOrEmbed { width: 100%; height: 100vh; } img { display: block; } '; - const html = `${attachmentDetails}${body.name}${img}`; - - return response.status(200).send(html); + response.set('Content-Type', body.mime); + return response.status(200).end(file); } default: { response.setHeader('Content-Disposition', `attachment; filename="${body.name}"`);