From 9fe8ffc084d135dbc1ed32efecf76c8ccfd438cf Mon Sep 17 00:00:00 2001 From: kukhariev Date: Sat, 11 Jul 2026 17:38:17 +0300 Subject: [PATCH 1/2] chore(examples): fix typos --- examples/custom-error-responses.ts | 2 +- examples/express-polling.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/custom-error-responses.ts b/examples/custom-error-responses.ts index f6f0e115..1f7f0397 100644 --- a/examples/custom-error-responses.ts +++ b/examples/custom-error-responses.ts @@ -11,7 +11,7 @@ const storage = new DiskStorage({ logLevel: 'debug', onError(response) { const { code, message } = response; - const page = (code || 'unknownerror').toLowerCase(); + const page = (code || 'UnknownError').toLowerCase(); const documentation_url = `http://example.com/api/v1/docs/upload/error/${page}`; const body = { message, documentation_url }; return { ...response, body }; diff --git a/examples/express-polling.ts b/examples/express-polling.ts index 788d3ab6..b0b08295 100644 --- a/examples/express-polling.ts +++ b/examples/express-polling.ts @@ -64,4 +64,4 @@ app.use('/files', upload, async (req, res) => { : res.json({ ...file, taskStatus: 'done' }); }); -app.listen(PORT, () => console.log(`Listing on port ${PORT}`)); +app.listen(PORT, () => console.log('listening on port:', PORT)); From a8b0aa6886bcec5c9cf9956cef1d88d25ddbdbd9 Mon Sep 17 00:00:00 2001 From: kukhariev Date: Sat, 11 Jul 2026 17:40:10 +0300 Subject: [PATCH 2/2] docs: add README for examples directory --- examples/README.md | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 examples/README.md diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 00000000..3acec870 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,85 @@ +# Examples + +This directory contains working examples demonstrating various use cases of `node-uploadx`. + +## Running Examples + +From the repository root, install dependencies and build `node-uploadx` packages first: + +```bash +npm install +npm run build +``` + +Then navigate to the examples directory and run the desired script: + +```bash +# Basic Express example +npm run basic + +# Express with default storage (local filesystem) +npm run express + +# Express with S3 storage +npm run s3 + +# Express with GCS storage +npm run gcs + +# Plain Node.js server combining Uploadx, TUS and Multipart protocols +npm run server + +# Plain Node.js HTTP server example +npm run plain-nodejs + +# Other examples... +npm run tus +npm run validation +npm run redis +npm run logtape +npm run custom-error-responses +npm run express-polling +``` + +## Example Descriptions + +| File | Description | +| -------------------------------------------------------- | ------------------------------------------------------------------- | +| [`express.ts`](express.ts) | Express example with authentication and logging | +| [`express-basic.ts`](express-basic.ts) | Minimal Express setup with local file storage | +| [`express-s3.ts`](express-s3.ts) | Upload to AWS S3 | +| [`express-gcs.ts`](express-gcs.ts) | Upload to Google Cloud Storage | +| [`express-tus.ts`](express-tus.ts) | Using the tus resumable upload protocol | +| [`express-polling.ts`](express-polling.ts) | Polling-based upload implementation | +| [`express-redis.ts`](express-redis.ts) | Using Redis for metadata storage | +| [`express-logtape.ts`](express-logtape.ts) | Logging with LogTape | +| [`custom-error-responses.ts`](custom-error-responses.ts) | Custom error handling and responses | +| [`validation.ts`](validation.ts) | File validation (type, size, custom rules) | +| [`s3-direct.ts`](s3-direct.ts) | Direct S3 upload | +| [`gcs-direct.ts`](gcs-direct.ts) | Direct GCS upload | +| [`node-http-server.js`](node-http-server.js) | Plain Node.js HTTP server example | +| [`server.js`](server.js) | Plain Node.js server combining Uploadx, TUS and Multipart protocols | + +## Prerequisites + +Most examples require environment variables. Copy `.env.example` to `.env` and fill in the values: + +```env +# Required for all examples +UPLOAD_DIR=./files + +# For S3 examples (aws s3, minio, etc.) +AWS_ACCESS_KEY_ID=your-access-key +AWS_SECRET_ACCESS_KEY=your-secret +AWS_REGION=us-east-1 +S3_BUCKET=your-bucket + +# For GCS examples +GCS_BUCKET=your-bucket +GCS_KEY_FILE=/path/to/key.json + +# Optional +UPLOADX_SECRET=your-secret-key +``` + +See `.env.example` for full environment variable reference.