1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-14 14:42:55 +01:00
server/cdn/README.md

113 lines
1.9 KiB
Markdown
Raw Normal View History

2021-02-09 10:00:35 +01:00
# Fosscord-CDN
2021-10-20 02:14:48 +02:00
2021-02-09 10:00:35 +01:00
CDN for Fosscord
2020-12-30 23:07:11 +01:00
2020-12-31 13:57:48 +01:00
## Run localy:
2021-10-20 02:14:48 +02:00
2020-12-31 13:57:48 +01:00
```
npm i
node dist/
```
2020-12-30 23:07:11 +01:00
## Endpoints:
2021-10-20 02:14:48 +02:00
2020-12-31 13:55:28 +01:00
### POST `/attachments/<filename>`
2021-10-20 02:14:48 +02:00
2020-12-31 13:54:40 +01:00
```
Content-Type: form-data
2020-12-30 23:07:11 +01:00
2020-12-31 13:56:35 +01:00
attachment: File (binary-data)
2020-12-31 13:54:40 +01:00
```
2021-10-20 02:14:48 +02:00
2020-12-31 13:54:40 +01:00
##### Returns:
2021-10-20 02:14:48 +02:00
2020-12-31 13:54:40 +01:00
```
{
"success": boolean, // true
"message": string, // "attachment uploaded"
"id": snowflake, // "794183329158135808"
"filename": string // "lakdoiauej.png"
}
```
2021-10-20 02:14:48 +02:00
2020-12-31 13:55:28 +01:00
### GET `/attachments/<id>/<filename>`
2021-10-20 02:14:48 +02:00
2020-12-31 13:54:40 +01:00
```
requests image from database with given <id> and <filename>
```
2021-10-20 02:14:48 +02:00
2020-12-31 13:54:40 +01:00
##### Returns:
2021-10-20 02:14:48 +02:00
2020-12-31 13:54:40 +01:00
```
Content-Type: image/<imageType(png,img,gif)>
Image
```
2021-10-20 02:14:48 +02:00
2020-12-31 13:55:28 +01:00
### DELETE `/attachments/<id>/<filename>`
2021-10-20 02:14:48 +02:00
2020-12-31 13:54:40 +01:00
```
deletes database entry
```
2021-10-20 02:14:48 +02:00
2020-12-31 13:54:40 +01:00
##### Returns:
2021-10-20 02:14:48 +02:00
2020-12-31 13:54:40 +01:00
```
Content-Type: application/json
{
"success": true,
"message": "attachment deleted"
}
```
<hr>
_(endpoints for crawler):_
2021-10-20 02:14:48 +02:00
### POST `/external`
2020-12-31 13:55:28 +01:00
2020-12-30 23:07:11 +01:00
```
2020-12-31 13:54:40 +01:00
requests crawling of `og:`metadata and the download of the `og:image` property
--------
2020-12-30 23:07:11 +01:00
Content-Type: application/json
body:
{"url": URL} // "https://discord.com"
```
2021-10-20 02:14:48 +02:00
2020-12-30 23:07:11 +01:00
##### Returns:
2021-10-20 02:14:48 +02:00
2020-12-31 13:54:40 +01:00
```
2020-12-30 23:07:11 +01:00
Content-Type: application/json
2020-12-31 13:54:40 +01:00
2020-12-30 23:07:11 +01:00
{
"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"
}
```
2021-10-20 02:14:48 +02:00
2020-12-31 13:55:28 +01:00
### GET `/external/<id>/<filename>`
2021-10-20 02:14:48 +02:00
- requests cached crawled image
2020-12-30 23:14:04 +01:00
```
url-params:
:id // aHR0cHM6Ly9kaXNjb3JkLmNvbQ==
:filename // discord.png
2020-12-30 23:17:45 +01:00
```
2021-10-20 02:14:48 +02:00
2020-12-30 23:17:45 +01:00
```
2020-12-30 23:14:04 +01:00
/external/aHR0cHM6Ly9kaXNjb3JkLmNvbQ==/discord.png
```
2021-10-20 02:14:48 +02:00
2020-12-30 23:14:04 +01:00
##### Returns:
2021-10-20 02:14:48 +02:00
2020-12-30 23:14:04 +01:00
```
Content-Type: image/<imageType(png,img,gif)>
Image
```