@feng3d/dingrtc-token-server
v0.0.5
Published
Express server for generating DingRTC tokens
Readme
@feng3d/dingrtc-token-server
Express server for generating DingRTC tokens.
Installation
npm install @feng3d/dingrtc-token-serverUsage
As a module
const server = require('@feng3d/dingrtc-token-server');
// Start server on default port 3001
server.start();
// Or with custom port
server.start(3002);As a CLI
npx @feng3d/dingrtc-token-serverAPI Endpoint
GET /login
Generate a token for DingRTC.
Query Parameters:
appId(required): Application IDchannelId(required): Channel IDuserId(required): User IDappKey(required): Application Key
Example:
GET http://localhost:3001/login?appId=your-app-id&channelId=your-channel-id&userId=your-user-id&appKey=your-app-keyResponse:
{
"data": {
"token": "generated-token-string"
}
}Configuration
Port Configuration
The server runs on port 3001 by default. You can change this by setting the PORT environment variable:
PORT=3002 node server.jsHTTPS Configuration
To enable HTTPS, you need to provide SSL certificate and key files via environment variables:
SSL_KEY_PATH=/path/to/private.key SSL_CERT_PATH=/path/to/certificate.crt node server.jsOr on Windows:
$env:SSL_KEY_PATH="C:\ssl\www.feng3d.com.key"
$env:SSL_CERT_PATH="C:\ssl\www.feng3d.com.pem"
dingrtc-token-serverExample with HTTPS:
GET https://localhost:3001/login?appId=your-app-id&channelId=your-channel-id&userId=your-user-id&appKey=your-app-keyUsing as Module with HTTPS
const server = require('@feng3d/dingrtc-token-server');
const fs = require('fs');
// Start HTTPS server
const sslOptions = {
key: fs.readFileSync('/path/to/private.key'),
cert: fs.readFileSync('/path/to/certificate.crt')
};
server.start(3001, sslOptions);License
MIT
