json-rest-api 1.0.1 → 1.0.2
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/docs/fileUploads.md +8 -8
- package/package.json +1 -1
package/docs/fileUploads.md
CHANGED
|
@@ -33,8 +33,8 @@ The file handling system consists of three main components:
|
|
|
33
33
|
|
|
34
34
|
```javascript
|
|
35
35
|
import { Api } from 'hooked-api';
|
|
36
|
-
import { RestApiPlugin, FileHandlingPlugin, ExpressPlugin } from '
|
|
37
|
-
import { LocalStorage } from '
|
|
36
|
+
import { RestApiPlugin, FileHandlingPlugin, ExpressPlugin } from 'json-rest-api';
|
|
37
|
+
import { LocalStorage } from 'json-rest-api/plugins/storage/local-storage.js';
|
|
38
38
|
|
|
39
39
|
// Create API
|
|
40
40
|
const api = new Api({ name: 'my-api', version: '1.0.0' });
|
|
@@ -122,7 +122,7 @@ Storage adapters handle where and how files are saved. The library includes two
|
|
|
122
122
|
Saves files to Amazon S3 or S3-compatible storage:
|
|
123
123
|
|
|
124
124
|
```javascript
|
|
125
|
-
import { S3Storage } from '
|
|
125
|
+
import { S3Storage } from 'json-rest-api/plugins/storage/s3-storage.js';
|
|
126
126
|
|
|
127
127
|
const s3Storage = new S3Storage({
|
|
128
128
|
bucket: 'my-uploads', // S3 bucket name (required)
|
|
@@ -144,7 +144,7 @@ const s3Storage = new S3Storage({
|
|
|
144
144
|
Saves files to the local filesystem with secure filename handling:
|
|
145
145
|
|
|
146
146
|
```javascript
|
|
147
|
-
import { LocalStorage } from '
|
|
147
|
+
import { LocalStorage } from 'json-rest-api/plugins/storage/local-storage.js';
|
|
148
148
|
|
|
149
149
|
const localStorage = new LocalStorage({
|
|
150
150
|
directory: './uploads', // Where to save files
|
|
@@ -411,8 +411,8 @@ When validation fails, you'll get appropriate error responses:
|
|
|
411
411
|
|
|
412
412
|
```javascript
|
|
413
413
|
import { Api } from 'hooked-api';
|
|
414
|
-
import { RestApiPlugin, FileHandlingPlugin, ExpressPlugin } from '
|
|
415
|
-
import { LocalStorage } from '
|
|
414
|
+
import { RestApiPlugin, FileHandlingPlugin, ExpressPlugin } from 'json-rest-api';
|
|
415
|
+
import { LocalStorage } from 'json-rest-api/plugins/storage/local-storage.js';
|
|
416
416
|
import express from 'express';
|
|
417
417
|
|
|
418
418
|
// Setup
|
|
@@ -493,7 +493,7 @@ api.addScope('articles', {
|
|
|
493
493
|
Different strategies for different use cases:
|
|
494
494
|
|
|
495
495
|
```javascript
|
|
496
|
-
import { LocalStorage } from '
|
|
496
|
+
import { LocalStorage } from 'json-rest-api/plugins/storage/local-storage.js';
|
|
497
497
|
|
|
498
498
|
// User avatars - use hash for security and deduplication
|
|
499
499
|
const avatarStorage = new LocalStorage({
|
|
@@ -649,7 +649,7 @@ Use the included example to test your setup:
|
|
|
649
649
|
|
|
650
650
|
```javascript
|
|
651
651
|
// Run the example
|
|
652
|
-
node ./node_modules/
|
|
652
|
+
node ./node_modules/json-rest-api/examples/file-upload-example.js
|
|
653
653
|
```
|
|
654
654
|
|
|
655
655
|
Then visit http://localhost:3000 to see the test forms.
|