1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-22 18:32:29 +01:00
server/cdn
dependabot[bot] e9a680beaf
Bump file-type from 16.5.3 to 16.5.4 in /cdn (#801)
Bumps [file-type](https://github.com/sindresorhus/file-type) from 16.5.3 to 16.5.4.
- [Release notes](https://github.com/sindresorhus/file-type/releases)
- [Commits](https://github.com/sindresorhus/file-type/compare/v16.5.3...v16.5.4)

---
updated-dependencies:
- dependency-name: file-type
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-23 09:46:55 +03:00
..
jest
src Update role-icons.ts 2022-01-09 23:28:26 +03:00
tests Improve build scripts, strip more fs-extras 2021-12-21 21:49:58 +01:00
.env.example
.gitignore added unittest setup + ping route test 2021-08-18 13:57:23 +02:00
.swcrc 🐛 fix swc config 2021-10-07 18:21:17 +02:00
Dockerfile Revert "fix: make the CDN build correctly" 2021-10-18 14:38:34 +02:00
package-lock.json Bump file-type from 16.5.3 to 16.5.4 in /cdn (#801) 2022-07-23 09:46:55 +03:00
package.json Bump file-type from 16.5.3 to 16.5.4 in /cdn (#801) 2022-07-23 09:46:55 +03:00
README.md prettier formatted /cdn 2021-10-20 09:14:48 +09:00
tsconfig.json prettier formatted /cdn 2021-10-20 09:14:48 +09: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