Using .env config

This commit is contained in:
2025-10-30 12:45:22 +01:00
parent edf8ef2b2d
commit 61679da20b
3 changed files with 36 additions and 1 deletions
+1
View File
@@ -25,6 +25,7 @@ target
/target /target
.env
*.db *.db
config.json config.json
+26
View File
@@ -2,6 +2,32 @@
The server for the DM and notification system of Voxa The server for the DM and notification system of Voxa
## Setup
### Using `config.json` (Usually when you self host)
`cargo run`
### Using `.env`
```python
#.env
VX_CONFIG='{"server_name":"Server Name","server_id":"<required>","server_key":"<required>","port":7090,"channels":[]}'
```
If your env is automatically loaded
```bash
cargo run
```
Run this if you are running on self host or when the .env isn't automatically loaded
```bash
set -a; source .env; set +a
cargo run
```
### What is a Voxa Node? ### What is a Voxa Node?
A voxa node is a server that handles DMs sent to you and push message notifications, a client will keep a constant connection with their chosen node and when a sender wants to send a DM or a message notification they can make a HTTP request to the same port, it's important to note that a node server only handles the receiving side, unless both parties are in the same node. A voxa node is a server that handles DMs sent to you and push message notifications, a client will keep a constant connection with their chosen node and when a sender wants to send a DM or a message notification they can make a HTTP request to the same port, it's important to note that a node server only handles the receiving side, unless both parties are in the same node.
+9 -1
View File
@@ -5,6 +5,7 @@ mod server;
mod types; mod types;
mod utils; mod utils;
use std::env;
use std::path::PathBuf; use std::path::PathBuf;
pub use anyhow::Context as ErrorContext; pub use anyhow::Context as ErrorContext;
@@ -16,7 +17,14 @@ use crate::utils::vfs;
fn main() -> Result<()> { fn main() -> Result<()> {
let root = PathBuf::from(""); let root = PathBuf::from("");
let config: ServerConfig = vfs::read_config(&root.join("config.json"))?;
let config: ServerConfig = if let Ok(env_config) = env::var("VX_CONFIG") {
serde_json::from_str(&env_config)?
} else {
vfs::read_config(&root.join("config.json"))?
};
config.build(&root).run()?; config.build(&root).run()?;
Ok(()) Ok(())
} }