- Install cargo:
sudo apt install cargo
- Create a postgres database instance using docker
cd scheduler
docker compose -f integrations/docker-compose.yml up -d
- Change some database configurations and environment keys
cd scheduler
export ACCOUNT_API_KEY="apikeytest"
export DATABASE_URL="postgresql://postgres:postgres@localhost:8000/nettuscheduler"
export PORT="3000"
export ADMIN_STAGING_URL="https://senior-concierge-admin-staging.up.railway.app"
export ADMIN_PRODUCTION_URL="https://senior-concierge-admin-production.up.railway.app"
- Also, change the clients port for this same env var (it's manual for now):
- Javascript:
scheduler/clients/javascript/lib/index.ts
line 46. - Rust:
scheduler/crates/infra/src/config.rs
line 36.
- Javascript:
- Comment or delete
scheduler/src/bin/migrate.ts
- Install sqlx:
cargo install sqlx-cli
- Change .bashrc path (see last command output) and use
source ~/.bashrc
- Run migrations:
sqlx migrate run --source crates/infra/migrations
- Run API:
cargo run
Nettu scheduler
is a self-hosted calendar and scheduler server that aims to provide the building blocks for building calendar / booking apps with ease. It has a simple REST API and also a JavaScript SDK and Rust SDK.
It supports authentication through api keys for server - server communication and JSON Web Tokens for browser - server communication.
- Booking: Create a
Service
and registerUser
s on it to make them bookable. - Calendar Events: Supports recurrence rules, flexible querying and reminders.
- Calendars: For grouping
Calendar Event
s. - Freebusy: Find out when
User
s are free and when they are busy. - Integrations: Connect your Nettu, Google and Outlook calendars
- Multi-tenancy: All resources are grouped by
Account
s. - Metadata queries: Add key-value metadata to your resources and then query on that metadata
- Webhooks: Notifying your server about
Calendar Event
reminders.
The server is using PostgreSQL for persistence, so we will need to spin up that first:
cd scheduler
docker-compose -f integrations/docker-compose.yml up -d
Now we are ready to start the nettu-scheduler
server with cargo
cd scheduler
export ACCOUNT_API_KEY="REPLACE_ME"
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/nettuscheduler"
export PORT="3000"
cargo run
The ACCOUNT_API_KEY
environment variable is going to create an Account
(if it does not already exist) during
server startup with the given key. Account
s act as tenants in the server, and it is possible to create multiple Account
s by using the CREATE_ACCOUNT_SECRET_CODE
which you can provide as an environment variable.
Quick example of how to create and query a user
export SECRET_API_KEY="REPLACE ME WITH YOUR API KEY"
# Create a user with metadata
curl -X POST -H "Content-Type: application/json" -H "x-api-key: $SECRET_API_KEY" -d '{"metadata": { "groupId": "123" }}' http://localhost:5000/api/v1/user
# Get users by metadata
curl -H "x-api-key: $SECRET_API_KEY" "http://localhost:5000/api/v1/user/meta?key=groupId&value=123"
Please see below for links to more examples.
Contributions are welcome and are greatly appreciated!
- Lemmy for inspiration on how to use cargo workspace to organize a web app in rust.
- The author of this blog post for an excellent introduction on how to do telemetry in rust.