A simple, lightweight data synchronization server for Electerm, built with Java and Spark. It provides a REST API for syncing bookmarks, history, and other data across Electerm instances.
- Java 17: Required for building and running the server. Download from Adoptium or your preferred JDK provider.
- Gradle: Included via the Gradle Wrapper (
gradlew), so no separate installation needed. - Git: For cloning the repository.
-
Clone the repository:
git clone https://github.com/electerm/electerm-sync-server-java.git cd electerm-sync-server-java -
Set up the environment file:
cp sample.env .env
Edit
.envwith your preferred settings (see Configuration below).
The server uses environment variables from a .env file for configuration. Key settings include:
JWT_SECRET: A secret key for JWT token signing (generate a strong random string).JWT_USER_NAME: Username for authentication.JWT_USER_PASSWORD: Password for authentication.PORT: Server port (default: 7837).DB_URL: H2 database URL (default: embedded database).
Example .env:
JWT_SECRET=your-super-secret-key-here
JWT_USER_NAME=admin
JWT_USER_PASSWORD=securepassword
PORT=7837
DB_URL=jdbc:h2:./electerm_sync_dbSecurity Note: Never commit .env to version control. Use strong, unique values for secrets.
For quick testing or development:
./gradlew run- Starts the server on
http://127.0.0.1:7837. - Output will show:
server running at http://127.0.0.1:7837. - Press
Ctrl+Cto stop.
-
Build the application:
./gradlew build
-
Extract the distribution:
tar -xvf build/distributions/electerm-sync-server-java.tar cd electerm-sync-server-java -
Run the server:
./bin/electerm-sync-server-java
- Runs in the foreground. Use
&to background it:./bin/electerm-sync-server-java &. - Access at
http://127.0.0.1:7837(or your configured port).
- Runs in the foreground. Use
- In Electerm, go to Settings > Sync.
- Select Custom Sync Server.
- Set:
- Server URL:
http://127.0.0.1:7837(or your server's URL). - JWT Secret: The
JWT_SECRETfrom your.env. - Username: The
JWT_USER_NAMEfrom your.env.
- Server URL:
- Save and sync your data.
The API endpoint is http://127.0.0.1:7837/api/sync.
Run the test suite:
./gradlew test- Uses JUnit for unit tests.
- Reports are in
build/reports/tests/test/index.html.
The server uses an H2 database by default, but you can implement custom storage.
- Implement the data store interface by extending or referencing
DataStore.java. - Update
App.javato use your custom store. - Rebuild and run.
Example: Take src/main/java/ElectermSync/DataStore.java as a reference for read/write methods.
For containerized deployment, see electerm-sync-server-java-docker.
Explore alternatives: Custom Sync Server Wiki.
MIT