add endpoint for oembed; restyle gifv; skeleton for websocket
This commit is contained in:
parent
ec3597e474
commit
e799724b3b
9 changed files with 312 additions and 209 deletions
|
@ -7,6 +7,8 @@ import which from "which";
|
|||
|
||||
import fs from "fs";
|
||||
|
||||
import { wss } from "./ws";
|
||||
|
||||
/**
|
||||
* Enum to represent different types of video encoding methods.
|
||||
*
|
||||
|
|
|
@ -31,7 +31,9 @@ export interface oembedObj {
|
|||
provider_name: string;
|
||||
provider_url: string;
|
||||
cache_age: number;
|
||||
title: string;
|
||||
html: string;
|
||||
url: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
}
|
||||
|
@ -54,4 +56,4 @@ export const imageExtensions = [
|
|||
".svg",
|
||||
".tiff",
|
||||
".webp",
|
||||
];
|
||||
];
|
|
@ -69,6 +69,8 @@ export const createEmbedData: Middleware = async (req, res, next) => {
|
|||
html: `<iframe src='${req.protocol}://${req.get(
|
||||
"host",
|
||||
)}/gifv/${filename}${fileExtension}'></iframe>`,
|
||||
title: filename,
|
||||
url: `${req.protocol}://${req.get("host")}/uploads/${filename}${fileExtension}`,
|
||||
};
|
||||
|
||||
if (isMedia) {
|
||||
|
|
20
app/lib/ws.ts
Normal file
20
app/lib/ws.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import WebSocket from "ws";
|
||||
|
||||
const wsPort = normalizePort(process.env.EBWSPORT || "3001");
|
||||
|
||||
function normalizePort(val: string) {
|
||||
const port = parseInt(val, 10);
|
||||
|
||||
if (isNaN(port)) {
|
||||
return parseInt(val);
|
||||
}
|
||||
|
||||
if (port >= 0) {
|
||||
return port;
|
||||
}
|
||||
}
|
||||
|
||||
const wss = new WebSocket.Server({port: wsPort});
|
||||
|
||||
export { wss };
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue