first commit
This commit is contained in:
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")
|
Reference in New Issue
Block a user