Skip to content

Commit d16f734

Browse files
author
Vlad Balin
committed
Added proxyIO endpoint
1 parent beb36de commit d16f734

File tree

12 files changed

+275
-2
lines changed

12 files changed

+275
-2
lines changed

endpoints/proxy/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Proxy Endpoint
2+
3+
Create IO endpoint from the Record class. This endpoint is designed for use on the server side data layer managed by Type-R.
4+
5+
Assuming that you have Type-R records with endpoints working with the database, you can create an endpoint which will use
6+
Record subclass as a transport.
7+
8+
import { proxyIO } from 'type-r/endpoint/proxy'
9+
10+
...
11+
12+
const usersIO = proxyIO( User );
13+
14+
This endpoint can be connected to the RESTful endpoint API on the server side which will serve JSON to the restfulIO endpoint on the client.
15+
An advantage of this approach is that JSON schema will be transparently validated on the server side by the Type-R.

endpoints/proxy/dist/index.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

endpoints/proxy/dist/index.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

endpoints/proxy/lib/index.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { IOEndpoint, Record } from 'type-r';
2+
export declare function proxyIO(record: typeof Record): ProxyEndpoint;
3+
export declare class ProxyEndpoint implements IOEndpoint {
4+
Record: typeof Record;
5+
readonly endpoint: IOEndpoint;
6+
constructor(record: typeof Record);
7+
subscribe(events: any, target: any): Promise<any>;
8+
unsubscribe(events: any, target: any): void;
9+
list(options: any): Promise<Object[]>;
10+
update(id: any, json: any, options: any): Promise<{
11+
_cas: any;
12+
}>;
13+
create(json: any, options: any): Promise<{
14+
id: any;
15+
_cas: any;
16+
_type: any;
17+
}>;
18+
read(id: any, options: object): Promise<Object>;
19+
destroy(id: string, options: object): Promise<{}>;
20+
}

0 commit comments

Comments
 (0)