summary refs log tree commit diff
path: root/cdn/README.md
blob: 7d8e99b05e5ef7dd82151dac96a28361b688368c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# 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"
}
```

<hr>

_(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
```