You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trim the README to a quick-start pointer to docs.lmnt.com/api/sdks/typescript
where the full SDK guide now lives. Remove the examples/ directory; the
docs site carries equivalent (and freshly maintained) snippets.
This library is typed for convenient access to the documented API. If you need to access undocumented
232
-
endpoints, params, or response properties, the library can still be used.
233
-
234
-
#### Undocumented endpoints
235
-
236
-
To make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.
237
-
Options on the client, such as retries, will be respected when making these requests.
238
-
239
-
```ts
240
-
awaitclient.post('/some/path', {
241
-
body: { some_prop: 'foo' },
242
-
query: { some_query_arg: 'bar' },
243
-
});
244
-
```
245
-
246
-
#### Undocumented request params
247
-
248
-
To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented
249
-
parameter. This library doesn't validate at runtime that the request matches the type, so any extra values you
250
-
send will be sent as-is.
251
-
252
-
```ts
253
-
client.foo.create({
254
-
foo: 'my_param',
255
-
bar: 12,
256
-
// @ts-expect-error baz is not yet public
257
-
baz: 'undocumented option',
258
-
});
259
-
```
260
-
261
-
For requests with the `GET` verb, any extra params will be in the query, all other requests will send the
262
-
extra param in the body.
263
-
264
-
If you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request
265
-
options.
266
-
267
-
#### Undocumented response properties
268
-
269
-
To access undocumented response properties, you may access the response object with `// @ts-expect-error` on
270
-
the response object, or cast the response object to the requisite type. Like the request params, we do not
271
-
validate or strip extra properties from the response from the API.
272
-
273
-
### Customizing the fetch client
274
-
275
-
By default, this library uses `node-fetch` in Node, and expects a global `fetch` function in other environments.
276
-
277
-
If you would prefer to use a global, web-standards-compliant `fetch` function even in a Node environment,
278
-
(for example, if you are running Node with `--experimental-fetch` or using NextJS which polyfills with `undici`),
279
-
add the following import before your first import `from "Lmnt"`:
280
-
281
-
```ts
282
-
// Tell TypeScript and the package to use the global web fetch instead of node-fetch.
283
-
// Note, despite the name, this does not add any polyfills, but expects them to be provided if needed.
284
-
import'lmnt-node/shims/web';
285
-
importLmntfrom'lmnt-node';
286
-
```
287
-
288
-
To do the inverse, add `import "lmnt-node/shims/node"` (which does import polyfills).
289
-
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/lmnt-com/lmnt-node/tree/master/src/_shims#readme)).
290
-
291
-
### Logging and middleware
292
-
293
-
You may also provide a custom `fetch` function when instantiating the client,
294
-
which can be used to inspect or alter the `Request` or `Response` before/after each request:
console.log('About to make a request', url, init);
303
-
const response =awaitfetch(url, init);
304
-
console.log('Got response', response);
305
-
returnresponse;
306
-
},
307
-
});
308
-
```
309
-
310
-
Note that if given a `DEBUG=true` environment variable, this library will log all requests and responses automatically.
311
-
This is intended for debugging purposes only and may change in the future without notice.
312
-
313
-
### Configuring an HTTP(S) Agent (e.g., for proxies)
314
-
315
-
By default, this library uses a stable agent for all http/https requests to reuse TCP connections, eliminating many TCP & TLS handshakes and shaving around 100ms off most requests.
316
-
317
-
If you would like to disable or customize this behavior, for example to use the API behind a proxy, you can pass an `httpAgent` which is used for all requests (be they http or https), for example:
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
341
-
342
-
1. Changes that only affect static types, without breaking runtime behavior.
343
-
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
344
-
3. Changes that we do not expect to impact the vast majority of users in practice.
345
-
346
-
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
347
-
348
-
We are keen for your feedback; please open an [issue](https://www.github.com/lmnt-com/lmnt-node/issues) with questions, bugs, or suggestions.
349
-
350
32
## Requirements
351
33
352
-
TypeScript >= 4.5 is supported.
353
-
354
-
The following runtimes are supported:
355
-
356
-
- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
357
-
- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
358
-
- Deno v1.28.0 or higher.
359
-
- Bun 1.0 or later.
360
-
- Cloudflare Workers.
361
-
- Vercel Edge Runtime.
362
-
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
363
-
- Nitro v2.6 or greater.
364
-
365
-
Note that React Native is not supported at this time.
366
-
367
-
If you are interested in other runtime environments, please open or upvote an issue on GitHub.
34
+
TypeScript >= 4.5 and Node.js 20 LTS or later are supported.
0 commit comments