coller/src/cmd/collerd/README.md
Julien Riou b5701b5a4d
All checks were successful
/ pre-commit (push) Successful in 1m20s
feat: replace Monaco by Ace
- Remove the Monaco Editor because it was to heavy and hard to integrate
- Use Ace instead
- Use the lowercase identifier for languages (ex: "Text" -> "text")
- Select automatically the default language in the drop down to create a note
  (like the expiration)
- Add `ace_directory` to serve assets from a local folder instead of a CDN
- "hcl" syntax highlighting has been removed
- "go" syntax highlighting has been renamed to "golang"
- Add option to disable the editor

Fixes #32.

Signed-off-by: Julien Riou <julien@riou.xyz>
2025-09-27 09:56:50 +02:00

136 lines
No EOL
4.8 KiB
Markdown

# collerd
Server to manage notes:
* Website
* API
* Database management
## Usage
```
collerd -help
```
## Configuration
The file format is **JSON**:
* **title** (string): Title of the website
* **database_type** (string): Type of the database (default "sqlite", "postgres" also supported)
* **database_dsn** (string): Connection string for the database (default "collerd.db")
* **node_id** (int): Number between 0 and 1023 to define the node generating identifiers (see [snowflake](https://github.com/bwmarrin/snowflake))
* **encryption_key_length** (int): Number of characters for generated encryption key (default 16)
* **allow_client_encryption_key** (bool): Allow encryption key provided by the client on the web UI
* **allow_no_encryption** (bool): Allow notes without encryption
* **enable_password_encryption** (bool): Enable password to protect notes (default true)
* **enable_upload_file_button** (bool): Display the upload file button in the UI (default true)
* **expiration_interval** (int): Number of seconds to wait between two expiration runs
* **listen_address** (string): Address to listen for the web server (default "0.0.0.0")
* **listen_port** (int): Port to listen for the web server (default 8080)
* **expirations** ([]int): List of supported expiration times in seconds (default 300, 86400, 604800, 18144000)
* **expiration** (int): Default expiration time in seconds
* **max_upload_size** (int): Maximum number of bytes received by the server for notes (the base64 encoding may use more space than the real size of the note)
* **show_version** (bool): Show version on the website
* **enable_metrics** (bool): Enable Prometheus endpoint (default true)
* **prometheus_route** (string): Route to expose Prometheus metrics (default "/metrics")
* **prometheus_notes_metric** (string): Name of the notes count metric (default "collerd_notes")
* **observation_internal** (int): Number of seconds to wait between two observations (default 60)
* **languages** ([]string): List of supported [languages](https://github.com/ajaxorg/ace/tree/master/src/mode)
* **language** (string): Default language (default "text")
* **tls_cert_file** (string): Path to TLS certificate file to enable HTTPS
* **tls_key_file** (string): Path to TLS key file to enable HTTPS
* **ace_directory** (string): Serve [Ace](hhttps://ace.c9.io/) assets from this local directory (ex: "./node_modules/ace-builds"). See **Dependencies** for details.
* **bootstrap_directory** (string): Serve [Bootstrap](https://getbootstrap.com/) assets from this local directory (ex: "./node_modules/bootstrap/dist"). See **Dependencies** for details.
* **disable_editor** (bool): Disable Ace editor.
The configuration file is not required but the service might not be exposed to the public.
## API
### GET /health
Returns 200 OK.
### POST /api/note
Create a note.
Body (JSON):
* **content** (string): base64 encoded content (required)
* **encryption_key** (string): use server-side encryption with this encryption key
* **encrypted** (bool): true if the content has been encrypted by the client
* **expiration** (int): lifetime of the note in seconds (must be supported by the server)
* **delete_after_read** (bool): delete the note after the first read
* **language** (string): language of the note (must be supported by the server)
Response (JSON):
* **id** (string): ID of the note
### GET /api/note/\<id\>/\<encryptionKey\>
> [!WARNING]
> Potential encryption key leak
Return content of a note encrypted by the given encryption key.
### POST /api/note/\<id\>/\<encryptionKey\>
> [!WARNING]
> Potential encryption key leak
Return content of a protected note encrypted by the given encryption key.
Body (JSON):
* **password** (string): password used to protect the note (required)
### GET /api/note/\<id\>
Return content of a note.
If the note is encrypted, the encrypted value is returned (application/octet-stream). Otherwise, the text is returned (text/plain).
### POST /api/note/\<id\>
Return content of a protected note.
If the note is encrypted, the encrypted value is returned (application/octet-stream). Otherwise, the text is returned (text/plain).
Body (JSON):
* **password** (string): password used to protect the note (required)
### Errors
Errors return **500 Server Internal Error** with the **JSON** payload:
* **message** (string): context of the error
* **error** (string): error message
## Dependencies
The web interface depends on:
- [Ace](https://ace.c9.io/)
- [Bootstrap](https://getbootstrap.com/)
By default, those dependencies are fetched from **remote CDN** services by the client.
If you would like to download and serve them locally:
```
npm install
```
or via `make`:
```
make dependencies
```
Then configure the local directories:
```json
{
"ace_directory": "./node_modules/ace-builds",
"bootstrap_directory": "./node_modules/bootstrap/dist"
}
```