@fileverse/api 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +142 -0
- package/dist/cli/index.js +1258 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/index.js +1548 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/index.js +17802 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.js +14052 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/worker.js +2846 -0
- package/dist/worker.js.map +1 -0
- package/package.json +93 -0
- package/public/llm.txt +621 -0
- package/public/openapi.json +922 -0
package/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Fileverse API
|
|
2
|
+
|
|
3
|
+
## Quick Start
|
|
4
|
+
|
|
5
|
+
The fastest way to get started is using the `@fileverse/api` CLI:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @fileverse/api
|
|
9
|
+
npx @fileverse/api --apiKey <key> --rpcUrl <url>
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
This will prompt for any missing values, set up configuration, run migrations, and start the server.
|
|
13
|
+
|
|
14
|
+
## Manual Setup
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
git clone <your-repo-url>
|
|
18
|
+
cd satellite
|
|
19
|
+
npm install
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Configure runtime variables via `config/.env` or `~/.fileverse/.env` (see Environment Variables). The CLI creates `~/.fileverse/.env` when you run `fileverse-api` with your API key.
|
|
23
|
+
|
|
24
|
+
### Building the Project
|
|
25
|
+
|
|
26
|
+
**Important:** After installation or when making code changes, you must build the project:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Clean old compiled code and rebuild
|
|
30
|
+
npm run clean && npm run build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`build` generates constants from `config/network.config.json` then runs tsup. For a build using dev config (e.g. to test against a local backend), use `npm run build:local` (uses `config/dev.network.config.json`).
|
|
34
|
+
|
|
35
|
+
**Why clean before build?**
|
|
36
|
+
|
|
37
|
+
- Ensures compiled code (`dist/`) matches your source code (`src/`)
|
|
38
|
+
- Prevents stale compiled code from causing errors
|
|
39
|
+
- Always run `npm run clean && npm run build` after:
|
|
40
|
+
- Initial setup
|
|
41
|
+
- Pulling new changes
|
|
42
|
+
- Making significant code changes
|
|
43
|
+
- Seeing errors that don't match your source code
|
|
44
|
+
|
|
45
|
+
For details on config flow and publishing, see [docs/CONFIG_AND_PUBLISH.md](docs/CONFIG_AND_PUBLISH.md).
|
|
46
|
+
|
|
47
|
+
## Run
|
|
48
|
+
|
|
49
|
+
### API Server
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm run start:api
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Note:** All `/api/*` endpoints require authentication via `?apiKey=<key>` query parameter. The API key is the same key provided during setup.
|
|
56
|
+
|
|
57
|
+
### Worker (for processing sync jobs)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm run start:worker
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Development
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Run API server (uses config/dev.network.config.json)
|
|
67
|
+
npm run dev
|
|
68
|
+
|
|
69
|
+
# Run worker in another terminal
|
|
70
|
+
npm run dev:worker
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`dev` and `dev:worker` generate constants from `config/dev.network.config.json` before starting.
|
|
74
|
+
|
|
75
|
+
## CLI Usage
|
|
76
|
+
|
|
77
|
+
The CLI tool `ddctl` provides commands to manage your ddocs from the command line.
|
|
78
|
+
|
|
79
|
+
### Setup
|
|
80
|
+
|
|
81
|
+
**Important:** All commands must be run from the project root directory (where `package.json` is located).
|
|
82
|
+
|
|
83
|
+
1. **Build the project:**
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm run clean && npm run build
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
2. **Set execute permissions and link globally:**
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
chmod +x dist/commands/index.js
|
|
93
|
+
npm link
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Note:** `npm link` must be run from the project root directory because it reads `package.json` to find the binary path.
|
|
97
|
+
|
|
98
|
+
3. **Verify installation:**
|
|
99
|
+
```bash
|
|
100
|
+
ddctl --help
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Usage
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Development mode (no build needed, uses ts-node)
|
|
107
|
+
npm run dev:cli list
|
|
108
|
+
|
|
109
|
+
# Production mode (uses compiled code)
|
|
110
|
+
ddctl list
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Events (failed recovery):** List failed sync events with `ddctl events list-failed`. Retry one with `ddctl events retry <eventId>` or all with `ddctl events retry-all`. Events are scoped by portal; the API (`GET /api/events/failed`, `POST /api/events/:id/retry`, `POST /api/events/retry-failed`) only lists and retries events for the portal of the API key.
|
|
114
|
+
|
|
115
|
+
**Note:** The CLI works from any directory because `DB_PATH` is resolved to an absolute path at startup.
|
|
116
|
+
|
|
117
|
+
## Environment Variables
|
|
118
|
+
|
|
119
|
+
Create a `.env` file in `config/` or `~/.fileverse/` with the following variables:
|
|
120
|
+
|
|
121
|
+
**Required:**
|
|
122
|
+
|
|
123
|
+
- `DB_PATH`: Database file path (required) - **Must be an absolute path**. Both API and CLI use the same database location.
|
|
124
|
+
- **Examples:**
|
|
125
|
+
- `DB_PATH=/Users/username/data/fileverse-api.db`
|
|
126
|
+
- `DB_PATH=/absolute/path/to/fileverse-api.db`
|
|
127
|
+
- **Important:**
|
|
128
|
+
- Use absolute paths only (e.g., `/Users/username/data/fileverse-api.db`)
|
|
129
|
+
- Relative paths will cause issues when running CLI from different directories
|
|
130
|
+
- The directory will be created automatically if it doesn't exist
|
|
131
|
+
- Both API server and CLI tool use the exact same database file
|
|
132
|
+
|
|
133
|
+
**Optional:**
|
|
134
|
+
|
|
135
|
+
- `PORT`: Server port (default: 8001)
|
|
136
|
+
- `IP`: Server IP (default: 127.0.0.1)
|
|
137
|
+
- `NODE_ENV`: Environment (development, production, etc.)
|
|
138
|
+
- `WORKER_CONCURRENCY`: Number of concurrent events to process (default: 5)
|
|
139
|
+
- `LOG_LEVEL`: Logging level - trace, debug, info, warn, error, fatal (default: info)
|
|
140
|
+
- `SERVICE_NAME`: Service name for logging (default: fileverse-api)
|
|
141
|
+
|
|
142
|
+
**Note:** The application will not start if `DB_PATH` is not set. Both the API server and CLI tool use the same database location specified by `DB_PATH`.
|