Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
jdoodle-client
Advanced tools
JavaScript JDoodle API client
npm install jdoodle-client
All distribution files are in node_modules/jdoodle-client/dist/
<script src="https://unpkg.com/jdoodle-client@latest/dist/jdoodle-client.browser.js"></script>
const jdoodle = require('jdoodle-client');
// Load JDOODLE_XXX process.env values for configuring endpoints and
// credentials from .env file. This prevents putting personal key info
// into version control. Example template.env is available in the dist folder
require('dotenv').load();
// Use the jdoodle object, example server code (using Koa) might look like that:
httpRouter.post(jdoodle.defaultExecutePath, async ctx => {
ctx.body = await jdoodle.execute(ctx.request.body);
});
httpRouter.post(jdoodle.defaultCreditSpentPath, async ctx => {
ctx.body = await jdoodle.creditSpent();
});
// Use the jdoodle (window.jdoodle) object, example browser code might look like that:
(() => { 'use strict';
const elem = id => document.getElementById(id);
const on = (t, e, h) => t.addEventListener(e, h);
const ready = h => on(document, 'DOMContentLoaded', h);
ready(() => {
on(elem('execute'), 'click', async () => {
// Gather language, versionIndex, stdin, script from UI elements
let json = await jdoodle.execute({
language,
versionIndex: Number(versionIndex) || 0,
stdin,
script
});
// Use returned json
});
on(elem('creditSpent'), 'click', async () => {
let json = await jdoodle.creditSpent();
// Use returned json
});
});
})();
// Node
import jdoodle from 'jdoodle-client/dist/jdoodle-client.node';
// Bundlers
import jdoodle from 'jdoodle-client';
// Use the imports
The following properties/functions are available through the jdoodle namespace object returned from require('jdoodle-client')
on node or available as window.jdoodle
in the browser (the ES module has the namespace object as default export):
version
- library version
execute([opts])
- execute code, the opts are:
endpoint
- node: JDoodle API endpoint, browser: your server endpointclientId
- (node only) JDoodle clientId, set via .envclientSecret
- (node only) JDoodle clientSecret, set via .envlanguage
- language codeversionIndex
- language version code (details about language and versionIndex codes)stdin
- standard inputscript
- program sourcecreditSpent([opts])
- check spent credit, the opts are:
endpoint
- node: JDoodle API endpoint, browser: your server endpointclientId
- (node only) JDoodle clientId, set via .envclientSecret
- (node only) JDoodle clientSecret, set via .envAll opts have defaults so just calling the functions is a quick test if things are properly set up, the return value is a promise resolving to JSON even in the presence of errors (containing limited information about the error), for more control use the callExecuteAPI
and callCreditSpentAPI
variants with appropriate error handling either via promise then-catch chain or try-catch block with async/await
See the example repo for complete code example (the relevant code is in app.js
, layout.pug
and index.pug
)
FAQs
JDoodle API client
The npm package jdoodle-client receives a total of 4 weekly downloads. As such, jdoodle-client popularity was classified as not popular.
We found that jdoodle-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.