1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-23 10:52:30 +01:00
server/cdn
2021-08-18 11:47:28 +02:00
..
src 🐛 fix types 2021-08-15 14:40:59 +02:00
.env.example cdn 2021-08-12 20:16:45 +02:00
.gitignore cdn 2021-08-12 20:16:45 +02:00
Dockerfile cdn 2021-08-12 20:16:45 +02:00
package-lock.json 🐛 fix findOneAndUpdate 2021-08-18 11:47:28 +02:00
package.json 🐛 build bundle 2021-08-15 22:36:35 +02:00
README.md cdn 2021-08-12 20:16:45 +02:00
tsconfig.json cdn 2021-08-12 20:16:45 +02:00

Fosscord-CDN

CDN for Fosscord

Run localy:

npm i
node dist/

Endpoints:

POST /attachments/<filename>

Content-Type: form-data

attachment: File (binary-data)
Returns:
{
    "success": boolean,             // true
    "message": string,              // "attachment uploaded"
    "id": snowflake,                // "794183329158135808"
    "filename": string              // "lakdoiauej.png"
}

GET /attachments/<id>/<filename>

requests image from database with given <id> and <filename>
Returns:
Content-Type: image/<imageType(png,img,gif)>
Image

DELETE /attachments/<id>/<filename>

deletes database entry
Returns:
Content-Type: application/json

{
    "success": true,
    "message": "attachment deleted"
}

(endpoints for crawler):

POST /external

requests crawling of `og:`metadata and the download of the `og:image` property
--------
Content-Type: application/json

body:
{"url": URL}                  // "https://discord.com"
Returns:
Content-Type: application/json

{
    "id": string,             // "aHR0cHM6Ly9kaXNjb3JkLmNvbQ=="
    "ogTitle": string,        // "Discord | Your Place to Talk and Hang Out"
    "ogDescription": string,  // "Discord is the easiest way to talk over voice, video, and text. Talk, chat, hang out, and stay close with your friends and communities."
    "cachedImage": string,    // "/external/aHR0cHM6Ly9kaXNjb3JkLmNvbQ==/discord.png"
    "ogUrl": string,          // "https://discord.com/"
    "ogType": string          // "website"
}

GET /external/<id>/<filename>

  • requests cached crawled image
url-params:
    :id                       // aHR0cHM6Ly9kaXNjb3JkLmNvbQ==
    :filename                 // discord.png
/external/aHR0cHM6Ly9kaXNjb3JkLmNvbQ==/discord.png
Returns:
Content-Type: image/<imageType(png,img,gif)>
Image