0.4.19 • Published 8 days ago

@neosync/sdk v0.4.19

Weekly downloads
-
License
MIT
Repository
github
Last release
8 days ago

Neosync TypeScript SDK

This SDK contains the generated types for Neosync API. This SDK is dogfooded by the main Neosync webapp to ensure its durability.

Installation

npm install @neosync/sdk

Usage

For a prime example of how to us this SDK, view the withNeosyncContext method in the Neosync app's BFF layer.

Note on Transports

Based on your usage, you'll have to install a different version of connect to provide the correct Transport based on your environment.

Install whichever one makes sense for you

npm install @connectrpc/connect-node
npm install @connectrpc/connect-web

Neosync API serves up Connect, which can listen using Connect, gRPC, or Web protocols. Each of the libraries above provides all three of those protocols, but it's recommended to use createConnectTransport for the most efficient setup.

import { getNeosyncClient } from '@neosync/sdk';
import { createConnectTransport } from '@connectrpc/connect-node';

const neosyncClient = getNeosyncClient({
  getTransport(interceptors) {
    return createConnectTransport({
      baseUrl: '<url>',
      httpVersion: '2',
      interceptors: interceptors,
    });
  },
});

Authenticating

To authenticate the TS Neosync Client, a function may be provided to the configuration that will be invoked prior to every request. This gives flexability in how the access token may be retrieved and supports either a Neosync API Key or a standard user JWT token.

When the getAccessToken function is provided, the Neosync Client is configured with an auth interceptor that attaches the Authorization header to every outgoingn request with the access token returned from the function. This is why the getTransport method receives a list of interceptors, and why it's important to hook them up to pass them through to the relevant transport being used.

import { getNeosyncClient } from '@neosync/sdk';
import { createConnectTransport } from '@connectrpc/connect-node';

const neosyncClient = getNeosyncClient({
  getAccessToken: () => process.env.NEOSYNC_API_KEY,
  getTransport(interceptors) {
    return createConnectTransport({
      baseUrl: process.env.NEOSYNC_API_URL,
      httpVersion: '2',
      interceptors: interceptors,
    });
  },
});

Neosync App

In the Neosync dashboard app, we pull the user access token off of the incoming request (auth is configured using next-auth.). This way we can ensure that all requests are using the user's access token and are passed through to Neosync API.

0.4.19

8 days ago

0.4.18

8 days ago

0.4.17

10 days ago

0.4.16

10 days ago

0.4.15

18 days ago

0.4.14

19 days ago

0.4.13

21 days ago

0.4.12

22 days ago

0.4.11

23 days ago

0.4.10

24 days ago

0.4.9

1 month ago

0.4.8

1 month ago

0.4.7

1 month ago

0.4.6

1 month ago

0.4.5

1 month ago

0.4.4

1 month ago

0.4.3

1 month ago

0.4.2

1 month ago

0.3.68

1 month ago

0.4.1

1 month ago

0.4.0

1 month ago

0.3.67

2 months ago

0.3.66

2 months ago

0.3.65

2 months ago

0.3.64

2 months ago

0.3.63

2 months ago

0.3.62

2 months ago

0.3.61

2 months ago

0.3.60

2 months ago

0.3.59

2 months ago

0.3.58

2 months ago

0.3.57

2 months ago

0.3.56

2 months ago

0.3.55

2 months ago

0.3.54

2 months ago

0.3.53

2 months ago

0.3.52

2 months ago

0.3.51

2 months ago

0.3.50

2 months ago

0.3.49

2 months ago

0.3.48

2 months ago

0.3.47

2 months ago

0.3.46

2 months ago

0.3.45

2 months ago

0.3.42

3 months ago

0.3.41

3 months ago

0.3.40

3 months ago

0.3.44

3 months ago

0.3.43

3 months ago

0.3.39

3 months ago

0.3.38

3 months ago

0.3.37

3 months ago

0.3.36

3 months ago

0.3.35

3 months ago

0.3.34

3 months ago

0.3.33

3 months ago

0.3.31

3 months ago

0.3.30

3 months ago

0.3.32

3 months ago

0.3.29

3 months ago

0.3.28

3 months ago

0.3.27

3 months ago

0.3.26

3 months ago

0.3.25

3 months ago

0.3.20

3 months ago

0.3.24

3 months ago

0.3.23

3 months ago

0.3.22

3 months ago

0.3.21

3 months ago

0.3.19

3 months ago

0.3.17

4 months ago

0.3.16

4 months ago

0.3.15

4 months ago

0.3.18

3 months ago

0.3.14

4 months ago

0.3.13

4 months ago

0.3.12

4 months ago

0.3.11

4 months ago

0.3.10

4 months ago

0.3.9

4 months ago

0.3.8

4 months ago

0.3.6

4 months ago

0.3.5

4 months ago

0.3.7

4 months ago

0.3.4

4 months ago

0.3.3

4 months ago

0.3.2

4 months ago

0.3.1

4 months ago

0.3.0

5 months ago

0.2.16

5 months ago

0.2.15

5 months ago

0.2.14

5 months ago

0.2.13

5 months ago

0.2.12

5 months ago

0.2.11

5 months ago

0.2.10

5 months ago

0.2.9

5 months ago

0.2.8

5 months ago

0.2.7

5 months ago

0.2.6

5 months ago

0.2.5

5 months ago

0.2.4

5 months ago

0.2.3

5 months ago

0.2.2

5 months ago

0.0.0

5 months ago

0.0.1-alpha1

5 months ago