New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

njp-piston

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

njp-piston

A simple node.js wrapper for the Piston API that works well with types.

latest
npmnpm
Version
0.0.10
Version published
Weekly downloads
3
200%
Maintainers
1
Weekly downloads
 
Created
Source

NJP Piston Library

Interact with the Piston API using this lightweight JavaScript/TypeScript wrapper.

Installation

Using npm:

npm install njp-piston

Usage

To use the Piston library, follow the below steps:

  • Import the piston method:
import { piston } from 'njp-piston';
  • Create an instance of Piston pointing to your Piston server:
const pistonInstance = await piston("http://localhost:2000");
  • Use the available methods on the instance:

Fetching Configuration

console.log(pistonInstance.configuration);

Getting Runtimes

const runtimes = await pistonInstance.getRuntimes();
console.log(runtimes);

Execute Source Code

In this example, we're executing a Python code that reads an input and prints a greeting:

const result = await pistonInstance.executeSourceCode(
    "r = input()\nprint('Hello ' + r)", 
    "python", 
    "World!"
);
console.log(result);

Example

Here's a complete example putting it all together:

import { piston } from 'njp-piston';

(async () => {
    const pistonInstance = await piston("http://localhost:2000");

    console.log(pistonInstance.configuration);
    console.log(await pistonInstance.getRuntimes());
    console.log(await pistonInstance.executeSourceCode("r = input()\nprint('Hello ' + r)", "python", "World!"));
})();

API Reference

Further API documentation can be found at the piston website https://piston.readthedocs.io/en/latest/api-v2/.

License

This library is released under the MIT License.

Keywords

piston

FAQs

Package last updated on 16 Sep 2023

Did you know?

Socket

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.

Install

Related posts