Installation & Setup
This guide covers installing Plugin Play and setting up your first plugin.
Prerequisites
- Node.js 18 or higher
- npm, yarn, or pnpm
- A Qelos application (for integration)
- Redis (optional, for caching)
Installation
Create a New Project
mkdir my-qelos-plugin
cd my-qelos-plugin
npm init -yInstall Plugin Play
npm install @qelos/plugin-playInstall TypeScript (Recommended)
npm install --save-dev typescript @types/node
npx tsc --initProject Structure
Create the following structure:
my-qelos-plugin/
├── src/
│ └── index.ts
├── public/ # Optional: for micro-frontend files
├── cert/ # Optional: for HTTPS in development
├── package.json
├── tsconfig.json
└── .envBasic Setup
1. Create Your Main File
Create src/index.ts:
import { start, configure } from '@qelos/plugin-play';
// Configure the plugin
configure({
name: 'My Plugin',
version: '1.0.0',
description: 'My first Qelos plugin',
manifestUrl: '/manifest.json',
proxyPath: '/api/proxy'
}, {
qelosUrl: process.env.QELOS_URL,
qelosUsername: process.env.QELOS_USERNAME,
qelosPassword: process.env.QELOS_PASSWORD,
port: 3000
});
// Start the server
start().then(() => {
console.log('Plugin is running!');
});2. Configure Environment Variables
Create .env:
# Qelos Connection
QELOS_URL=https://your-qelos-app.com
QELOS_USERNAME=plugin-user@example.com
QELOS_PASSWORD=your-password
# Server Configuration
PORT=3000
HOST=0.0.0.0
NODE_ENV=development
# Security (generate secure random strings)
REFRESH_TOKEN_SECRET=your-refresh-token-secret
ACCESS_TOKEN_SECRET=your-access-token-secret
USER_PAYLOAD_SECRET=your-user-payload-secret
# Optional: Redis for caching
REDIS_URL=redis://localhost:6379
# Optional: Static files
STATIC_ROOT=public
STATIC_PREFIX=/3. Update package.json
Add scripts to your package.json:
{
"name": "my-qelos-plugin",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "tsc",
"start": "node dist/index.js",
"create-certs": "node -e \"require('@qelos/plugin-play/create-cert')\""
},
"dependencies": {
"@qelos/plugin-play": "^3.10.0"
},
"devDependencies": {
"tsx": "^4.7.0",
"typescript": "^4.9.5",
"@types/node": "^20.0.0"
}
}4. Configure TypeScript
Update tsconfig.json:
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "node",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}Development Setup
Install Development Tools
npm install --save-dev tsx nodemonCreate HTTPS Certificates (Development)
For local HTTPS development:
npm run create-certsThis creates self-signed certificates in the cert/ directory.
Run in Development Mode
npm run devYour plugin should now be running at https://localhost:3000 (or http://localhost:3000 if no certificates).
Verify Installation
Check the Manifest
Visit http://localhost:3000/manifest.json to see your plugin manifest:
{
"name": "My Plugin",
"version": "1.0.0",
"description": "My first Qelos plugin",
"appUrl": "http://localhost:3000",
"proxyUrl": "http://localhost:3000/api/proxy",
"manifestUrl": "/manifest.json",
"subscribedEvents": [],
"microFrontends": [],
"cruds": [],
"injectables": [],
"navBarGroups": []
}Test the Health Endpoint
Plugin Play automatically creates a health check endpoint:
curl http://localhost:3000/api/healthAdding Your First Endpoint
Update src/index.ts:
import { start, configure, addEndpoint } from '@qelos/plugin-play';
configure({
name: 'My Plugin',
version: '1.0.0',
description: 'My first Qelos plugin',
manifestUrl: '/manifest.json',
proxyPath: '/api/proxy'
}, {
qelosUrl: process.env.QELOS_URL,
qelosUsername: process.env.QELOS_USERNAME,
qelosPassword: process.env.QELOS_PASSWORD
});
// Add a simple endpoint
addEndpoint('/api/hello', {
method: 'GET',
handler: async (request, reply) => {
return {
message: 'Hello from my plugin!',
timestamp: new Date().toISOString()
};
}
});
start();Test it:
curl http://localhost:3000/api/helloRegister with Qelos
To register your plugin with a Qelos application:
- Log in to your Qelos admin panel
- Navigate to Plugins
- Click "Add Plugin"
- Enter your plugin's manifest URL:
http://localhost:3000/manifest.json - Save
Your plugin is now registered and can receive events from the Qelos platform!
Production Setup
Environment Configuration
For production, use proper environment variables:
# Production .env
NODE_ENV=production
PORT=3000
HOST=0.0.0.0
QELOS_URL=https://your-qelos-app.com
QELOS_USERNAME=plugin-user@example.com
QELOS_PASSWORD=secure-password
# Use strong secrets in production
REFRESH_TOKEN_SECRET=<generate-secure-random-string>
ACCESS_TOKEN_SECRET=<generate-secure-random-string>
USER_PAYLOAD_SECRET=<generate-secure-random-string>
# Production Redis
REDIS_URL=redis://your-redis-server:6379Build for Production
npm run build
npm startDocker Deployment
Create Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist ./dist
COPY public ./public
EXPOSE 3000
CMD ["node", "dist/index.js"]Build and run:
docker build -t my-qelos-plugin .
docker run -p 3000:3000 --env-file .env my-qelos-pluginTroubleshooting
Port Already in Use
Change the port in your .env file:
PORT=3001Cannot Connect to Qelos
Verify your credentials:
curl -X POST https://your-qelos-app.com/api/signin \
-H "Content-Type: application/json" \
-d '{"username":"plugin-user@example.com","password":"your-password"}'HTTPS Certificate Errors
For development, you can disable HTTPS by removing the cert/ directory.
Redis Connection Issues
Redis is optional. If you don't need caching, you can omit the REDIS_URL environment variable.
