gtpl-node-compiler
v2.0.0
Published
`gtpl-node-compiler` is a lightweight Node.js module that provides three core utilities:
Readme
gtpl-node-compiler
gtpl-node-compiler is a lightweight Node.js module that provides three core utilities:
- Execute JavaScript code securely.
- Prompt an AI model with a custom prompt and API key.
- Perform a simple health check.
✨ Features
- 🔐 Safe Code Execution: Run code in a sandboxed environment.
- 🤖 AI Prompting Utility: Fetch templates/Snippets from AI model.
- 🩺 Health Check: Useful for monitoring or readiness probes.
📦 Installation
npm install gtpl-node-compiler
## 🛠️ Usage
import { fnRunCode, fnPromptAI, fnHealth } from 'gtpl-node-compiler';
-------------------------------"Run Code"-------------------------------------
// Run JavaScript code
#req.body -
{
code : <string> e.g "return 2 + 2;"
}
app.post('/run', fnRunCode);
------------------------------"Prompt AI"--------------------------------------
#req.body -
{
prompt: <string>,
key: <string>
}
app.post('/post', fnPromptAI);
---------------------------"Health check"---------------------------------------
app.post('/health', fnHealth);