enders-sync-client 0.1.0 → 0.1.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/README.md +8 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ npm install enders-sync-client
|
|
|
73
73
|
|
|
74
74
|
```javascript
|
|
75
75
|
import express from 'express';
|
|
76
|
-
import { useExpressRPC } from '
|
|
76
|
+
import { useExpressRPC } from 'enders-sync';
|
|
77
77
|
|
|
78
78
|
const app = express();
|
|
79
79
|
app.use(express.json());
|
|
@@ -105,7 +105,7 @@ app.listen(3000, () => {
|
|
|
105
105
|
**api.js**:
|
|
106
106
|
|
|
107
107
|
```javascript
|
|
108
|
-
import { RPC } from '
|
|
108
|
+
import { RPC } from 'enders-sync-client';
|
|
109
109
|
|
|
110
110
|
// Create RPC client instance
|
|
111
111
|
export const api = new RPC('/api/public');
|
|
@@ -158,7 +158,7 @@ function UserProfile({ userId }) {
|
|
|
158
158
|
```javascript
|
|
159
159
|
import express from 'express';
|
|
160
160
|
import jwt from 'jsonwebtoken';
|
|
161
|
-
import { useExpressRPC } from '
|
|
161
|
+
import { useExpressRPC } from 'enders-sync';
|
|
162
162
|
|
|
163
163
|
const app = express();
|
|
164
164
|
|
|
@@ -228,7 +228,7 @@ const adminRPC = useExpressRPC(app, '/api/admin', validateAdminToken);
|
|
|
228
228
|
**Client:**
|
|
229
229
|
|
|
230
230
|
```javascript
|
|
231
|
-
import { RPC } from "
|
|
231
|
+
import { RPC } from "enders-sync-client"
|
|
232
232
|
|
|
233
233
|
export const publicAPI = new RPC('/api/public');
|
|
234
234
|
export const userAPI = new RPC('/api/user');
|
|
@@ -343,8 +343,6 @@ Manually call an RPC function (usually not needed - use auto-generated methods i
|
|
|
343
343
|
|
|
344
344
|
[Go Back](#table-of-content)
|
|
345
345
|
|
|
346
|
-
[Go Back](#table-of-content)
|
|
347
|
-
|
|
348
346
|
When you create an RPC endpoint at `/api/public`, two routes are automatically created:
|
|
349
347
|
|
|
350
348
|
- `GET /api/public/discover` - Returns list of available functions
|
|
@@ -395,7 +393,7 @@ api.riskyOperation(data)
|
|
|
395
393
|
[Go Back](#table-of-content)
|
|
396
394
|
|
|
397
395
|
```typescript
|
|
398
|
-
import { type AuthMetadata } from '
|
|
396
|
+
import { type AuthMetadata } from 'enders-sync';
|
|
399
397
|
|
|
400
398
|
interface User{
|
|
401
399
|
id:
|
|
@@ -424,7 +422,7 @@ publicRPC.add(getUser);
|
|
|
424
422
|
[Go Back](#table-of-content)
|
|
425
423
|
|
|
426
424
|
```typescript
|
|
427
|
-
import { RPC } from '
|
|
425
|
+
import { RPC } from 'enders-sync-client';
|
|
428
426
|
|
|
429
427
|
export interface PublicAPI {
|
|
430
428
|
getUser(userId: number): Promise<{ id: number, name: string , email: string }>;
|
|
@@ -457,7 +455,7 @@ const user: User = await public_api.getUser(123);
|
|
|
457
455
|
|
|
458
456
|
```javascript
|
|
459
457
|
import express from 'express';
|
|
460
|
-
import { useExpressRPC } from '
|
|
458
|
+
import { useExpressRPC } from 'enders-sync';
|
|
461
459
|
|
|
462
460
|
const app = express();
|
|
463
461
|
app.use(express.json());
|
|
@@ -497,7 +495,7 @@ app.listen(3000);
|
|
|
497
495
|
**api.js**:
|
|
498
496
|
|
|
499
497
|
```javascript
|
|
500
|
-
import { RPC } from '
|
|
498
|
+
import { RPC } from 'enders-sync-client';
|
|
501
499
|
|
|
502
500
|
export const api = new RPC('/api/public');
|
|
503
501
|
```
|
package/package.json
CHANGED