Skip to content

Commit bae2fdb

Browse files
committed
chore: run oxfmt and fix lint issues
1 parent 4b90351 commit bae2fdb

File tree

100 files changed

+900
-2342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+900
-2342
lines changed

.github/workflows/cd-nildb-image.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
create-and-push-manifest:
7575
runs-on: ubuntu-latest
7676
timeout-minutes: 5
77-
needs: [ setup, build-and-push-arch ]
77+
needs: [setup, build-and-push-arch]
7878
steps:
7979
- name: Log in to GitHub Container Registry
8080
uses: docker/login-action@v3
@@ -97,7 +97,7 @@ jobs:
9797
IMAGE_BASE="ghcr.io/nillionnetwork/nildb"
9898
AMD64_IMAGE="${IMAGE_BASE}:${{ needs.setup.outputs.short_sha }}-amd64"
9999
ARM64_IMAGE="${IMAGE_BASE}:${{ needs.setup.outputs.short_sha }}-arm64"
100-
100+
101101
echo "${{ steps.meta.outputs.tags }}" | while IFS= read -r tag; do
102102
if [ -n "$tag" ]; then
103103
echo "Creating and pushing manifest for tag: ${tag}"
@@ -107,13 +107,13 @@ jobs:
107107
done
108108
109109
deploy-to-ci-cluster:
110-
needs: [ setup, create-and-push-manifest ]
110+
needs: [setup, create-and-push-manifest]
111111
runs-on: ubuntu-latest
112112
timeout-minutes: 5
113113
if: github.ref_name == 'main'
114114
strategy:
115115
matrix:
116-
node: [ "ci-n1", "ci-n2", "ci-n3" ]
116+
node: ["ci-n1", "ci-n2", "ci-n3"]
117117
steps:
118118
- name: Dispatch event to start nildb-infra/.github/workflows/ecs-${{ matrix.node }}.yaml workflow
119119
run: |

.spectral.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
extends: [ "spectral:oas" ]
1+
extends: ["spectral:oas"]

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This guide explains how to set up your development environment and contribute co
1111
## Development Setup
1212

1313
1. Clone the repository:
14+
1415
```shell
1516
git clone git@github.com:NillionNetwork/nildb.git
1617
cd nildb
@@ -42,6 +43,7 @@ pnpm test # run the full test suite
4243
```
4344

4445
> [!NOTE]
46+
>
4547
> - Tests use isolated collections (test_nildb and test_nildb_data)
4648
> - The test database is dropped at the start of each test run
4749

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ If you're unsure where to start, head over to [docs.nillion.com](https://docs.ni
1111

1212
- [Run a local cluster for development](./docs/build-on-nildb.md)
1313
- [Help build nilDB](./CONTRIBUTING.md)
14-
- [nilDB overview and network basics](./docs/overview.md)
14+
- [nilDB overview and network basics](./docs/overview.md)
1515
- [Want to be a node operator?](./docs/node-operator-questionnaire.md)
1616
- [Node admin guide](./docs/admin-guide.md)
1717

commitlint.config.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import { RuleConfigSeverity, type UserConfig } from "@commitlint/types";
33
const config: UserConfig = {
44
extends: ["@commitlint/config-conventional"],
55
rules: {
6-
"body-max-line-length": [
7-
RuleConfigSeverity.Disabled,
8-
"always",
9-
Number.POSITIVE_INFINITY,
10-
],
6+
"body-max-line-length": [RuleConfigSeverity.Disabled, "always", Number.POSITIVE_INFINITY],
117
},
128
};
139

docs/admin-guide.md

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,31 @@ This section provides task-oriented instructions for node administrators.
1818

1919
The following environment variables are require:
2020

21-
| Variable | Description | Example |
22-
|--------------------------|----------------------------------------------------------------|------------------------------------------|
23-
| APP_DB_NAME_BASE | Database name prefix | nildb_data |
24-
| APP_DB_URI | MongoDB connection string | mongodb://node-xxxx-db:27017 |
25-
| APP_ENABLED_FEATURES | Enable features | openapi-spec,metrics,migrations,otel |
26-
| APP_LOG_LEVEL | Logging verbosity | debug |
27-
| APP_METRICS_PORT | Prometheus metrics port | 9091 |
28-
| APP_NILAUTH_INSTANCES | Trusted nilauth instances (format: `baseUrl/publicKey,...`) | [see below] |
29-
| APP_NILAUTH_CHAIN_ID | Ethereum chain ID for payment validation | 1 |
30-
| APP_NODE_PUBLIC_ENDPOINT | Public URL of node | https://nildb-xxxx.domain.com |
31-
| APP_NODE_SECRET_KEY | Node's private key | [hex encoded secp256k1 private key] |
32-
| APP_PORT | API service port | 8080 |
21+
| Variable | Description | Example |
22+
| ------------------------ | ----------------------------------------------------------- | ------------------------------------ |
23+
| APP_DB_NAME_BASE | Database name prefix | nildb_data |
24+
| APP_DB_URI | MongoDB connection string | mongodb://node-xxxx-db:27017 |
25+
| APP_ENABLED_FEATURES | Enable features | openapi-spec,metrics,migrations,otel |
26+
| APP_LOG_LEVEL | Logging verbosity | debug |
27+
| APP_METRICS_PORT | Prometheus metrics port | 9091 |
28+
| APP_NILAUTH_INSTANCES | Trusted nilauth instances (format: `baseUrl/publicKey,...`) | [see below] |
29+
| APP_NILAUTH_CHAIN_ID | Ethereum chain ID for payment validation | 1 |
30+
| APP_NODE_PUBLIC_ENDPOINT | Public URL of node | https://nildb-xxxx.domain.com |
31+
| APP_NODE_SECRET_KEY | Node's private key | [hex encoded secp256k1 private key] |
32+
| APP_PORT | API service port | 8080 |
3333

3434
### Nilauth Configuration
3535

3636
The `APP_NILAUTH_INSTANCES` variable configures which nilauth instances this node trusts for builder authentication. Each instance is specified as `baseUrl/publicKey`, with multiple instances separated by commas.
3737

3838
**Single instance:**
39+
3940
```bash
4041
APP_NILAUTH_INSTANCES=http://nilauth:8080/03520e70bd97a5fa6d70c614d50ee47bf445ae0b0941a1d61ddd5afa022b97ab14
4142
```
4243

4344
**Multiple instances:**
45+
4446
```bash
4547
APP_NILAUTH_INSTANCES=http://nilauth-a:8080/03520e70bd97a5fa...,http://nilauth-b:8080/02abc123def456...
4648
```
@@ -49,19 +51,18 @@ APP_NILAUTH_INSTANCES=http://nilauth-a:8080/03520e70bd97a5fa...,http://nilauth-b
4951

5052
The following variables control the IP-based rate limiting feature.
5153

52-
| Variable | Description | Default |
53-
|---------------------------------|-------------------------------------------------|---------|
54-
| APP_RATE_LIMIT_ENABLED | Enables the rate-limiting feature. | `true` |
55-
| APP_RATE_LIMIT_WINDOW_SECONDS | The duration of the time window in seconds. | `60` |
56-
| APP_RATE_LIMIT_MAX_REQUESTS | Max requests per IP within the time window. | `60` |
57-
54+
| Variable | Description | Default |
55+
| ----------------------------- | ------------------------------------------- | ------- |
56+
| APP_RATE_LIMIT_ENABLED | Enables the rate-limiting feature. | `true` |
57+
| APP_RATE_LIMIT_WINDOW_SECONDS | The duration of the time window in seconds. | `60` |
58+
| APP_RATE_LIMIT_MAX_REQUESTS | Max requests per IP within the time window. | `60` |
5859

5960
### OpenTelemetry
6061

6162
When the `otel` feature is enabled in `APP_ENABLED_FEATURES`, the following variables configure OpenTelemetry instrumentation:
6263

6364
| Variable | Description | Default | Required |
64-
|---------------------------------|-----------------------------------------|------------------|----------|
65+
| ------------------------------- | --------------------------------------- | ---------------- | -------- |
6566
| OTEL_ENDPOINT | OTLP endpoint URL | http://localhost | No |
6667
| OTEL_SERVICE_NAME | Service name for telemetry | nildb | No |
6768
| OTEL_TEAM_NAME | Team responsible for the service | nildb | No |
@@ -95,6 +96,7 @@ Values set via `OTEL_RESOURCE_ATTRIBUTES` take precedence over programmatically
9596
**Disabling OpenTelemetry SDK:**
9697

9798
To disable OpenTelemetry SDK and prevent telemetry emission while keeping the `otel` feature flag enabled, set the following environment variable:
99+
98100
```bash
99101
OTEL_SDK_DISABLED=true
100102
```
@@ -113,6 +115,7 @@ docker compose -f local/docker-compose.yaml up -d
113115
```
114116

115117
This stack includes:
118+
116119
- **nilDB**: The main API service (port 40080, metrics port 40091)
117120
- **MongoDB**: Database backend (port 40017)
118121
- **nilauth**: Authentication service for NUC tokens (port 40921)
@@ -124,6 +127,7 @@ This stack includes:
124127
The nilDB API will be available at `http://localhost:40080`.
125128

126129
The local stack is configured with `APP_ENABLED_FEATURES=openapi,otel,migrations`, which means:
130+
127131
- Metrics, traces, and logs are sent to the OTel Collector (visible in `docker compose logs otel-collector`)
128132
- No `/metrics` endpoint is exposed (OTLP push only)
129133

@@ -176,6 +180,7 @@ The following endpoints provide operational information:
176180

177181
> ![NOTE]
178182
> The `/metrics` endpoint behavior depends on feature flags:
183+
>
179184
> - **`metrics` only**: Serves metrics at `:9091/metrics` using OpenTelemetry PrometheusExporter
180185
> - **`otel` enabled**: No `/metrics` endpoint; all telemetry pushed to OTLP collector
181186
>
@@ -225,8 +230,8 @@ For user-facing operations, there is an OpenAPI documentation interface hosted a
225230

226231
Configure MongoDB with the following backup/snapshot policy. This policy applies to both MongoDB Atlas and self-hosted MongoDB. Details specific to each are mentioned further below.
227232

228-
* Full hourly snapshots with 1-day retention
229-
* Full daily snapshots with 7-day retention; configured snapshot time: 04:00 UTC
233+
- Full hourly snapshots with 1-day retention
234+
- Full daily snapshots with 7-day retention; configured snapshot time: 04:00 UTC
230235

231236
### MongoDB Atlas
232237

docs/build-on-nildb.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ This section outlines specific builder-related tasks and is deliberately utilita
66

77
An OpenAPI documentation site is available at `{APP_NODE_PUBLIC_ENDPOINT}/openapi.json` when the node is running and the `openapi-spec` feature is enabled.
88

9-
109
## Running nilDB Locally
1110

1211
### Quick Start
@@ -20,7 +19,7 @@ docker compose -f local/docker-compose.yaml up -d
2019
This starts a single nilDB node along with all required supporting services:
2120

2221
- **nilDB API**: http://localhost:40080
23-
- **MongoDB**: localhost:40017
22+
- **MongoDB**: localhost:40017
2423
- **nilauth**: http://localhost:40921 (authentication service)
2524
- **nilchain**: http://localhost:40648 (local blockchain)
2625
- **PostgreSQL**: localhost:40432 (nilauth database)

docs/overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ nilDb is a structured data persistence service that provides a robust, distribut
66

77
- [Networks](#networks)
88
- [Network topology](#network-topology)
9-
- [Clusters](#clusters)
10-
- [Node Architecture](#node-architecture)
9+
- [Clusters](#clusters)
10+
- [Node Architecture](#node-architecture)
1111
- [Clients](#clients)
1212

1313
## Networks
@@ -65,4 +65,4 @@ curl https://nildb-a50d.nillion.network/api/v1/data/create \
6565
-d @data.json
6666
```
6767

68-
> ![NOTE] Data encryption is applied using [nilQL-ts](https://github.com/nillionnetwork/nilql-ts) or [nilQL-py](https://github.com/nillionnetwork/nilql-py) before transmission.
68+
> ![NOTE] Data encryption is applied using [nilQL-ts](https://github.com/nillionnetwork/nilql-ts) or [nilQL-py](https://github.com/nillionnetwork/nilql-py) before transmission.

lefthook.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
pre-commit:
22
commands:
3-
biome-format:
3+
oxfmt:
44
glob: "*.{ts,json,jsonc}"
55
# Uses pnpm directly (not justfile) because:
66
# - Requires lefthook's {staged_files} variable for incremental formatting
77
# - Uses stage_fixed to auto-stage formatted files (lefthook-specific)
8-
run: pnpm exec biome format --write --no-errors-on-unmatched --files-ignore-unknown=true --colors=off {staged_files}
8+
run: pnpm exec oxfmt {staged_files}
99
stage_fixed: true
1010

1111
commit-msg:

packages/api/UPGRADING.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This document explains how to upgrade nilDB between major versions.
55
## Version Compatibility
66

77
| From Version | To Version | Upgrade Path |
8-
|---------------|------------|-------------------------------|
8+
| ------------- | ---------- | ----------------------------- |
99
| Fresh install | 1.2.0+ | Direct install |
1010
| 1.1.2 | 1.2.0+ | Direct upgrade |
1111
| < 1.1.2 | 1.2.0+ | **Two-step upgrade required** |
@@ -15,6 +15,7 @@ This document explains how to upgrade nilDB between major versions.
1515
### Overview
1616

1717
Version 1.2.0 consolidates the database migration system:
18+
1819
- **Migration library**: Changed from `mongo-migrate-ts` to `migrate-mongo`
1920
- **Changelog collection**: Renamed from `migrations_changelog` to `_migrations`
2021
- **Migration count**: Reduced from 5 migrations to 1 consolidated migration
@@ -37,31 +38,37 @@ mongosh <connection-string> --eval "db.migrations_changelog.count()"
3738
### Upgrade Steps
3839

3940
1. **Backup your database**
41+
4042
```bash
4143
mongodump --uri="<your-mongodb-uri>" --out=/path/to/backup
4244
```
4345

4446
2. **Stop the current nilDB instance**
47+
4548
```bash
4649
docker stop <nildb-container>
4750
```
4851

4952
3. **Pull the new version**
53+
5054
```bash
5155
docker pull <nildb-image>:1.2.0
5256
```
5357

5458
4. **Start the new version**
59+
5560
```bash
5661
docker start <nildb-container>
5762
```
5863

5964
5. **Monitor the migration**
65+
6066
```bash
6167
docker logs -f <nildb-container>
6268
```
6369

6470
You should see:
71+
6572
```
6673
! Running consolidated init migration
6774
! Detected upgrade from v1.1.2
@@ -72,6 +79,7 @@ mongosh <connection-string> --eval "db.migrations_changelog.count()"
7279
```
7380

7481
6. **Verify the upgrade**
82+
7583
```bash
7684
# Check new changelog format
7785
mongosh <connection-string> --eval "db._migrations.findOne()"
@@ -85,6 +93,7 @@ mongosh <connection-string> --eval "db.migrations_changelog.count()"
8593
### What Happens During Upgrade
8694

8795
The migration automatically:
96+
8897
1. Detects the old `migrations_changelog` collection from v1.1.2
8998
2. Validates it contains exactly 5 expected migrations
9099
3. Drops the old `migrations_changelog` collection
@@ -111,6 +120,7 @@ Follow the [v1.1.2 → v1.2.0 upgrade steps](#upgrading-from-v112-to-v120) above
111120
## Fresh Installation
112121

113122
For new installations, simply start the latest version. The migration will:
123+
114124
1. Create all 7 collections (`builders`, `users`, `collections`, `queries`, `query_runs`, `config`, `data`)
115125
2. Create required indexes:
116126
- `builders.did` (unique)
@@ -126,6 +136,7 @@ For new installations, simply start the latest version. The migration will:
126136
**Cause**: Your database is not from v1.1.2.
127137

128138
**Solution**:
139+
129140
- If you're on an older version, first upgrade to v1.1.2
130141
- If migrations are incomplete, manually run v1.1.2 migrations to completion
131142
- If uncertain, restore from backup and contact support
@@ -135,6 +146,7 @@ For new installations, simply start the latest version. The migration will:
135146
**Cause**: The migration files in your v1.1.2 installation don't match expected names.
136147

137148
**Solution**:
149+
138150
- Verify you're running official v1.1.2 release
139151
- Check for custom or modified migrations
140152
- Restore from backup if migrations were tampered with
@@ -144,6 +156,7 @@ For new installations, simply start the latest version. The migration will:
144156
**Cause**: The old migration system didn't create a `migrations_changelog` collection.
145157

146158
**Solution**:
159+
147160
- This is expected for fresh installations (not an error)
148161
- For upgrades, verify you actually had v1.1.2 running previously
149162
- If uncertain, treat as fresh install (will recreate collections)
@@ -153,11 +166,13 @@ For new installations, simply start the latest version. The migration will:
153166
If you need to rollback after upgrading:
154167

155168
1. **Stop the new version**
169+
156170
```bash
157171
docker stop <nildb-container>
158172
```
159173

160174
2. **Restore from backup**
175+
161176
```bash
162177
mongorestore --uri="<your-mongodb-uri>" --drop /path/to/backup
163178
```

0 commit comments

Comments
 (0)