first commit
This commit is contained in:
1
.env.example
Normal file
1
.env.example
Normal file
@ -0,0 +1 @@
|
|||||||
|
PRIVATE_KEY=
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.env
|
||||||
|
node_modules/
|
||||||
|
tmp/
|
14
bun.lock
Normal file
14
bun.lock
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"lockfileVersion": 1,
|
||||||
|
"workspaces": {
|
||||||
|
"": {
|
||||||
|
"name": "processing",
|
||||||
|
"dependencies": {
|
||||||
|
"dotenv": "^17.1.0",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"packages": {
|
||||||
|
"dotenv": ["dotenv@17.1.0", "", {}, "sha512-tG9VUTJTuju6GcXgbdsOuRhupE8cb4mRgY5JLRCh4MtGoVo3/gfGUtOMwmProM6d0ba2mCFvv+WrpYJV6qgJXQ=="],
|
||||||
|
}
|
||||||
|
}
|
30
index.js
Normal file
30
index.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { $ } from "bun";
|
||||||
|
import 'dotenv/config'
|
||||||
|
Bun.serve({
|
||||||
|
port: 6001,
|
||||||
|
routes: {
|
||||||
|
"/status": new Response("OK"),
|
||||||
|
"/process": {
|
||||||
|
POST: async req => {
|
||||||
|
if(req.headers.get("X-Authentication") == process.env.PRIVATE_KEY) {
|
||||||
|
let path = "tmp/" + Bun.randomUUIDv7();
|
||||||
|
await Bun.write(path + ".mp4", await req.body.blob());
|
||||||
|
await $`ffmpeg -i ${path}.mp4 -map_metadata -1 -map 0 -map -0:v -b:a 64k ${path}.ogg`
|
||||||
|
await (Bun.file(path + ".mp4")).delete();
|
||||||
|
console.log("deleted req file");
|
||||||
|
let response = new Response(await Bun.file(path + ".ogg").bytes(), {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/ogg",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
await (Bun.file(path + ".ogg")).delete();
|
||||||
|
return response;
|
||||||
|
} else {
|
||||||
|
return new Response("Not Authenticated", { status: 401 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log("http://localhost:6001")
|
14
package.json
Normal file
14
package.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "processing",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "bun --watch index.js"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"description": "",
|
||||||
|
"dependencies": {
|
||||||
|
"dotenv": "^17.1.0"
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user