Skip to content

Commit 1ce2a3f

Browse files
committed
docs: add README for examples directory
1 parent 49459e9 commit 1ce2a3f

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

examples/README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Examples
2+
3+
This directory contains working examples demonstrating various use cases of `node-uploadx`.
4+
5+
## Running Examples
6+
7+
From the repository root, install dependencies and build `node-uploadx` packages first:
8+
9+
```bash
10+
npm install
11+
npm run build
12+
```
13+
14+
Then navigate to the examples directory and run the desired script:
15+
16+
```bash
17+
# Basic Express example
18+
npm run basic
19+
20+
# Express with default storage (local filesystem)
21+
npm run express
22+
23+
# Express with S3 storage
24+
npm run s3
25+
26+
# Express with GCS storage
27+
npm run gcs
28+
29+
# Plain Node.js server combining Uploadx, TUS and Multipart protocols
30+
npm run server
31+
32+
# Plain Node.js HTTP server example
33+
npm run plain-nodejs
34+
35+
# Other examples...
36+
npm run tus
37+
npm run validation
38+
npm run redis
39+
npm run logtape
40+
npm run custom-error-responses
41+
npm run express-polling
42+
```
43+
44+
## Example Descriptions
45+
46+
| File | Description |
47+
| -------------------------------------------------------- | ------------------------------------------------------------------- |
48+
| [`express.ts`](express.ts) | Express example with authentication and logging |
49+
| [`express-basic.ts`](express-basic.ts) | Minimal Express setup with local file storage |
50+
| [`express-s3.ts`](express-s3.ts) | Upload to AWS S3 |
51+
| [`express-gcs.ts`](express-gcs.ts) | Upload to Google Cloud Storage |
52+
| [`express-tus.ts`](express-tus.ts) | Using the tus resumable upload protocol |
53+
| [`express-polling.ts`](express-polling.ts) | Polling-based upload implementation |
54+
| [`express-redis.ts`](express-redis.ts) | Using Redis for metadata storage |
55+
| [`express-logtape.ts`](express-logtape.ts) | Logging with LogTape |
56+
| [`custom-error-responses.ts`](custom-error-responses.ts) | Custom error handling and responses |
57+
| [`validation.ts`](validation.ts) | File validation (type, size, custom rules) |
58+
| [`s3-direct.ts`](s3-direct.ts) | Direct S3 upload |
59+
| [`gcs-direct.ts`](gcs-direct.ts) | Direct GCS upload |
60+
| [`node-http-server.js`](node-http-server.js) | Plain Node.js HTTP server example |
61+
| [`server.js`](server.js) | Plain Node.js server combining Uploadx, TUS and Multipart protocols |
62+
63+
## Prerequisites
64+
65+
Most examples require environment variables. Copy `.env.example` to `.env` and fill in the values:
66+
67+
```env
68+
# Required for all examples
69+
UPLOAD_DIR=./files
70+
71+
# For S3 examples (aws s3, minio, etc.)
72+
AWS_ACCESS_KEY_ID=your-access-key
73+
AWS_SECRET_ACCESS_KEY=your-secret
74+
AWS_REGION=us-east-1
75+
S3_BUCKET=your-bucket
76+
77+
# For GCS examples
78+
GCS_BUCKET=your-bucket
79+
GCS_KEY_FILE=/path/to/key.json
80+
81+
# Optional
82+
UPLOADX_SECRET=your-secret-key
83+
```
84+
85+
See `.env.example` for full environment variable reference.

0 commit comments

Comments
 (0)