Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
caccl-api
Advanced tools
A class that defines a set of smart Canvas endpoints that actually behave how you'd expect them to.
A class that defines a set of Canvas endpoints that can be easily accessed. Each endpoint is equipped with the appropriate pre- and post-processing steps to make the Canvas endpoints "behave". For instance, getSubmissions() fetches student submissions and removes the test student's submission in post-processing.
// Import
const CanvasAPI = require('caccl-canvas-api');
// Create CanvasAPI instance
const api = new CanvasAPI({
canvasHost: 'canvas.instructor.com',
accessToken: '5368~059382...3e57293hga3',
cache: 'memory',
});
// Hit an endpoint
api.course.listStudents({
courseId: 52618,
})
.then((students) => {
// ...
})
.catch((err) => {
// ...
});
For a full list of supported endpoints, check out the /docs
folder.
'canvas.instructure.com'
['memory', 'session', 'custom']
cacheType
equals 'session'
, req
must be included and cache is stored in the express session.cacheType
equals 'custom'
, your custom cache must be included as cache
(see below).'session'
cacheType.'custom'
cacheType (see below).caccl-visit-endpoint
. You can use your own visitEndpoint function, though we recommend using caccl-visit-endpoint
anyway and just swapping out the sendRequest
function when creating an instance of caccl-visit-endpoint
.If using cacheType = 'custom'
, you need to include an instance of your own custom cache. We use a nested cache. Given an endpoint path
and params
, there should be one value
stored. For instance, we might want to store the following:
path: '/api/v1/courses'
params: { include: ['term'] }
value: [ /* courses with terms */ ]
and
path: '/api/v1/courses'
params: { include: ['sections'] }
value: [ /* courses with sections */ ]
Thus, path
isn't enough to save/retrieve cache entries.
If your cache has the ability to store promises as values*, your cache instance should have a property to indicate this:
cache.storePromises = true;
Your cache should include the following functions (all return Promises):
(path [string], params [object])
. Resolves with undefined
or null
if no cached value(path [string], params [object])
Example of cache in use:
cache.set('/api/v1/courses', { include: ['sections'] }, courseList1);
> cache contents:
> - /api/v1/courses
> - { include: ['sections'] } = courseList1
cache.set('/api/v1/courses', { include: ['term'] }, courseList2);
> cache contents:
> - /api/v1/courses
> - { include: ['sections'] } = courseList1
> - { include: ['term'] } = courseList2
cache.set('/api/v1/users/self/profile', {}, myProfile);
> cache contents:
> - /api/v1/courses
> - { include: ['sections'] } = courseList1
> - { include: ['term'] } = courseList2
> - /api/v1/users/self/profile
> - {} = myProfile
cache.get('/api/v1/users/self/profile', {})
> myProfile
cache.getAllPaths()
> ['/api/v1/courses', '/api/v1/users/self/profile']
cache.deletePaths(['/api/v1/courses'])
> cache contents:
> - /api/v1/users/self/profile
> - {} = myProfile
cache.deleteAllPaths()
> cache contents (empty)
* If possible, we like storing promises instead of values. This allows us to further optimize/speed up Canvas integration. Say you call api.course.listStudents(...)
and before that function returns, you call listStudents
again. Ordinarily, your second request would find that we have no cached value (yet) and we would send the request again (twice the requests we need!). If your cache allows storing Promises, we store unfinished calls to the api immediately. Thus, when you call listStudents
the second time, we'll just give you the pending promise from the first call, and when that first request finishes, both calls to listStudents
resolve simultaneously. We just cut the number of requests in half and the second call resolved earlier. Note: the built-in session
cache does not support Promises, but the built-in memory
cache does support Promises.
Canvas
App
Complete
Connection
Library
FAQs
A class that defines a set of smart Canvas endpoints that actually behave how you'd expect them to.
The npm package caccl-api receives a total of 329 weekly downloads. As such, caccl-api popularity was classified as not popular.
We found that caccl-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.