-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
67 lines (52 loc) Β· 3.97 KB
/
README
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
------------ πποΈ Simple Cache: Temporary (or not?) file hosting ------------
============================== Made by @voxelin ==============================
> WARNING: This branch is used specially to integrate with PostgreSQL. However, it is recommended to use TimescaleDB.
> If you have the TimescaleDB extension installed, please refer to origin/timescale.
## Introduction
----------------------------------
Simple Cache is a service for minimalistic temporary (or not?) file hosting.
SC allows you to upload any file via `curl`, `httpie`, or any other HTTP client
and store it for a specified number of days (or forever).
## Routes
----------------------------------
* GET `/` - Returns a 403 status code.
* POST `/` - Uploads a file from multipart/form-data (Field: `file` or `url`).
* GET `/:id` - Loads a file preview in the browser if possible. If not, download the file.
## Configuration
----------------------------------
The configuration can be done either via the file or the environment variables. The priority of loading is as follows:
| LOAD DEFAULT VALUES | ---> | LOAD CONFIG.HCL | ---> | LOAD ENVIRONMENT VARIABLES |
If some keys exist in multiple places (e.g., server.port in `config.hcl` and SC_SERVER_PORT is given), then the latest load is prioritized. (Environment variables are superior.)
### `config.hcl`
Example `config.hcl`:
------------------------------------------------------------------------
server {
serverName = "Simple Cache v1.2.4" # Sets the `Server` header for each response
appName = "Simple Cache" # Sets the app name to display in terminal
port = 8080 # Server port
databaseUrl = "postgres://user:password@localhost:5432/db" # PostgreSQL Connection URL
seed = 3719 # Seed for ID generation [type: random number > 0]
}
logger {
forceColors = false # Force colored output
fullTimestamp = true
}
limits {
maxSize = 10 # Max uploaded body size in MB
blockTor = false # Block TOR exit nodes
ipBlacklist = [] # ["168.0.2.3", "1.2.3.4"...]
}
------------------------------------------------------------------------
### Environment Variables
Configuration can also be done through environment variables. See the table below.
| Environment | Alternative in `config.hcl` | Default Value | Description |
|-------------------------|-----------------------------|-----------------------|--------------------------------------------|
| SC_SERVER_SERVERNAME | server.serverName | "Simple Cache v1.2.4" | `Server` header for each response |
| SC_SERVER_APPNAME | server.appName | "Simple Cache" | App name to display in the terminal |
| SC_SERVER_PORT | server.port | 8080 | Server port |
| SC_SERVER_DATABASEURL | server.databaseURL | [placeholder] | PostgreSQL Connection URL |
| SC_SERVER_SEED | server.seed | 3719 | Seed for ID generation [random number > 0] |
| SC_LOGGER_FORCECOLORS | logger.forceColors | false | Force colored output |
| SC_LOGGER_FULLTIMESTAMP | logger.fullTimestamp | true | - |
| SC_LIMITS_MAXSIZE | limits.maxSize | 10 | Max uploaded body size in MB |
| SC_LIMITS_BLOCKTOR | limits.blockTor | false | Block TOR exit nodes |