canvas-client
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -1,4 +0,4 @@ | ||
var _a; | ||
var _a, _b; | ||
import { CanvasAPI } from './canvas'; | ||
export * from './browser'; | ||
export const canvasAPI = new CanvasAPI(process.env.CANVAS_BASE_URL, ((_a = process.env.CANVAS_TOKENS) !== null && _a !== void 0 ? _a : '').split(',')); | ||
export const canvasAPI = new CanvasAPI(process.env.CANVAS_BASE_URL, ((_a = process.env.CANVAS_TOKENS) !== null && _a !== void 0 ? _a : '').split(','), { maxConnections: parseInt((_b = process.env.CANVAS_CONN_PER_TOKEN) !== null && _b !== void 0 ? _b : '10', 10) }); |
@@ -16,3 +16,3 @@ "use strict"; | ||
}; | ||
var _a; | ||
var _a, _b; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -22,2 +22,2 @@ exports.canvasAPI = void 0; | ||
__exportStar(require("./browser"), exports); | ||
exports.canvasAPI = new canvas_1.CanvasAPI(process.env.CANVAS_BASE_URL, ((_a = process.env.CANVAS_TOKENS) !== null && _a !== void 0 ? _a : '').split(',')); | ||
exports.canvasAPI = new canvas_1.CanvasAPI(process.env.CANVAS_BASE_URL, ((_a = process.env.CANVAS_TOKENS) !== null && _a !== void 0 ? _a : '').split(','), { maxConnections: parseInt((_b = process.env.CANVAS_CONN_PER_TOKEN) !== null && _b !== void 0 ? _b : '10', 10) }); |
{ | ||
"name": "canvas-client", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Typescript library to make accessing the Canvas API more convenient.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# canvas-client | ||
Typescript library to make accessing the Canvas API more convenient. | ||
# Features | ||
## Typescript | ||
The canvas client provided by this library has a lot of pre-built methods where we have carefully observed the behavior of the Canvas RESTful API and provided types that accurately reflect what it accepts and returns. The pre-built methods are not complete but they should cover the most common endpoints for server-to-server integrations like course, user, and assignment management. | ||
## Rate-limiting and token-splitting | ||
Canvas rate-limits incoming requests to about 20 simultaneous requests per account. This can be rather problematic if you are performing server-to-server operations on behalf of the entire campus via a single service account. This library's solution is two-fold: | ||
* Rate-limit on the client side to ensure canvas never gets overloaded. This way requests to Canvas never fail simply for rate-limiting. | ||
* The default client-side rate limit is a conservative 10 simultaneous requests. It's configurable. If multiple instances of your app share the same token, you may want to reduce this number. | ||
* Support multiple tokens (each MUST come from a separate user account) and load-balance requests across the tokens. This increases your total capacity. | ||
* Note that if you run multiple instances, you STILL want to reduce the max simultaneous requests per token, to avoid getting errors when you have a backlog of requests overwhelming the capacity of your tokens. | ||
## GraphQL | ||
We've provided a very simple method for making queries against Canvas' GraphQL API. It only takes care of the fundamentals of GraphQL. We do not provide types for | ||
graphql queries, but the `graphql` method does accept a generic so that you can provide the expected return type yourself. GraphQL requests also benefit from token splitting and rate limiting. Tokens and rate limits are shared with RESTful requests. | ||
# Testing | ||
@@ -5,0 +20,0 @@ Duplicate `.env.example`, rename it to `.env` and fill in good values for each of the variables. This will allow you to run `npm test` successfully. |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
133369
24
6