Add multi-user support via token-based routing and users.json config
Each user gets a unique secret token embedded in their webhook URL (/webhook/:token). Credentials are loaded from users.json at startup instead of environment variables, making it easy to add or remove users without redeploying. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
1 parent
902cd59d11
commit
68be646f37
4 files changed
+88
-24
No files matched your search
@@ -1,27 +1,65 @@
|
||||
# AudioPen Nextcloud Webhook
|
||||
|
||||
A small Node.js webhook service that receives notes from AudioPen and uploads them to a folder in Nextcloud using WebDAV.
|
||||
A small Node.js webhook service that receives notes from AudioPen and uploads them to a folder in Nextcloud using WebDAV. Supports multiple users, each with their own Nextcloud credentials and a unique webhook token.
|
||||
|
||||
When AudioPen sends a webhook request, the service:
|
||||
|
||||
1. Receives the note content
|
||||
2. Creates a timestamped Markdown file
|
||||
3. Uploads the file to the configured Nextcloud folder
|
||||
1. Validates the token in the URL
|
||||
2. Receives the note content
|
||||
3. Creates a timestamped Markdown file
|
||||
4. Uploads the file to the configured Nextcloud folder
|
||||
|
||||
Example filename:
|
||||
|
||||
```text
|
||||
note-2026-05-19T22-15-10.123Z.md
|
||||
2026-05-19T22-15-10.123Z-my-note-title.md
|
||||
```
|
||||
|
||||
## Example `.env`
|
||||
## Setup
|
||||
|
||||
Create a file named `.env` in the project root directory:
|
||||
### 1. Configure users
|
||||
|
||||
Copy `users.json.example` to `users.json` and fill in credentials for each user:
|
||||
|
||||
```json
|
||||
{
|
||||
"abc123secrettoken": {
|
||||
"nextcloudUrl": "https://nextcloud.example.com",
|
||||
"username": "alice",
|
||||
"password": "alice-app-password",
|
||||
"folder": "AudioPen"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Each key is a secret token that identifies a user. Generate one with:
|
||||
|
||||
```bash
|
||||
node -e "console.log(crypto.randomUUID())"
|
||||
```
|
||||
|
||||
### 2. Configure the server
|
||||
|
||||
Optionally create a `.env` file to set the port or a custom path to `users.json`:
|
||||
|
||||
```env
|
||||
NEXTCLOUD_URL=https://nextcloud.example.com
|
||||
NEXTCLOUD_USERNAME=myuser
|
||||
NEXTCLOUD_PASSWORD=my-app-password
|
||||
NEXTCLOUD_FOLDER=AudioPen
|
||||
PORT=3000
|
||||
```
|
||||
USERS_FILE=users.json
|
||||
```
|
||||
|
||||
### 3. Run
|
||||
|
||||
```bash
|
||||
npm install
|
||||
node server.js
|
||||
```
|
||||
|
||||
### 4. Configure AudioPen
|
||||
|
||||
In AudioPen's webhook settings, set the URL to:
|
||||
|
||||
```
|
||||
https://your-server/webhook/<token>
|
||||
```
|
||||
|
||||
Each user gets their own URL containing their unique token.
|
||||
Reference in new issue
Block a user