Skip to content

kyee-rs/sc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

------------ ๐Ÿ“‚๐Ÿ—„๏ธ 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                       |


About

๐Ÿ“‚๐Ÿ—„๏ธ Simple Cache: Upload temporary (or not?) files to your server via the command line.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks