base44-etoro-backend-functions-infra
v1.2.3
Published
eToro backend functions infrastructure for Base44, including header generation utilities
Maintainers
Readme
base44-etoro-backend-functions-infra
eToro backend functions infrastructure for Base44, providing utilities for generating eToro API headers.
Installation
npm install base44-etoro-backend-functions-infraUsage
In Deno
import { getEtoroHeaders } from 'npm:base44-etoro-backend-functions-infra';
// In your Deno.serve handler
const headers = await getEtoroHeaders(req, user);Options
The function accepts an optional third parameter for configuration:
const headers = await getEtoroHeaders(req, user, {
apiKey: 'your-api-key',
userKey: 'your-user-key'
});If options are not provided, the function will attempt to read from Deno.env:
ETORO_API_KEYETORO_USER_KEY
Function Details
getEtoroHeaders(req, user, options?)
Generates appropriate headers for eToro API requests.
Parameters:
req(Request): The incoming request objectuser(Object): The authenticated user object with arolepropertyoptions(Object, optional): Configuration optionsapiKey(string): eToro API keyuserKey(string): eToro user key
Returns:
Promise<Object>: Headers object containing:x-request-id: UUID v4Content-Type: 'application/json'Authorization: Bearer token (if SSO token provided)x-api-keyandx-user-key: API credentials (if admin role and no SSO token)
Throws:
- Error if user is not admin and no SSO token is provided
