Xeku.Scripts.WebApi 0.0.0.7

dotnet add package Xeku.Scripts.WebApi --version 0.0.0.7
                    
NuGet\Install-Package Xeku.Scripts.WebApi -Version 0.0.0.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Xeku.Scripts.WebApi" Version="0.0.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Xeku.Scripts.WebApi" Version="0.0.0.7" />
                    
Directory.Packages.props
<PackageReference Include="Xeku.Scripts.WebApi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Xeku.Scripts.WebApi --version 0.0.0.7
                    
#r "nuget: Xeku.Scripts.WebApi, 0.0.0.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Xeku.Scripts.WebApi@0.0.0.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Xeku.Scripts.WebApi&version=0.0.0.7
                    
Install as a Cake Addin
#tool nuget:?package=Xeku.Scripts.WebApi&version=0.0.0.7
                    
Install as a Cake Tool

Xeku.Scripts.WebApi

WebApi module for Xeku.Scripts, providing remote script execution endpoints via REST API.

Features

  • Remote Execution: Execute compiled scripts via HTTP POST endpoint
  • Timeout Support: Built-in 30-second timeout mechanism (configurable)
  • Execution Logging: Automatic logging of all remote executions
  • ScriptContext Support: Optional ScriptContext injection for XAF interactions
  • Standard Authentication: Compatible with JWT Bearer and ApiKey authentication

Installation

dotnet add package Xeku.Scripts.WebApi

Dependencies

  • Xeku.Core.WebApi - Core WebApi module
  • Xeku.Scripts - Scripts core module (required)
  • DevExpress.ExpressApp.Api.Xpo.All - XAF OData support

Integration

1. Module Registration

Add to your WebApi project's Startup.cs:

builder.Modules
    .Add<Xeku.Scripts.WebApi.ScriptsWebApiModule>();

2. Authentication Configuration

This module uses standard [Authorize] attribute. Ensure your Startup.cs has proper authentication configured:

Option A: JWT Bearer (Standard)

services.AddAuthentication()
    .AddJwtBearer(options => {
        // JWT configuration
    });

Option B: ApiKey (Recommended for external integration)

// Install Xeku.ApiKey.WebApi module
builder.Modules
    .Add<Xeku.ApiKey.WebApi.ApiKeyWebApiModule>();

API Endpoints

POST /api/ScriptsController/Execute

Executes a compiled script remotely.

Request Body:

{
  "scriptId": "guid-of-compiled-script",
  "withContext": true,
  "timeoutSeconds": 30
}
Parameter Type Required Default Description
scriptId Guid Yes - The GUID of the script to execute
withContext bool No true Whether to inject ScriptContext parameter
timeoutSeconds int No 30 Execution timeout in seconds

Response (Success - 200 OK):

{
  "success": true,
  "executionLogId": "guid",
  "returnValue": "result or null",
  "durationMs": 123,
  "messages": ["[INFO] Hello from Script!", "[WARN] ..."]
}

Response (Error - 400/404/500):

{
  "type": "https://xeku.dev/errors/execution-failed",
  "title": "Execution Failed",
  "status": 400,
  "detail": "Script not compiled or specific error message"
}

Usage Examples

Using curl with ApiKey

curl -X POST "https://your-api.com/api/ScriptsController/Execute" \
  -H "Authorization: ApiKey YOUR_API_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{
    "scriptId": "12345678-1234-1234-1234-123456789abc",
    "withContext": true,
    "timeoutSeconds": 30
  }'

Using C# HttpClient

using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "ApiKey YOUR_API_KEY");

var request = new
{
    scriptId = Guid.Parse("12345678-1234-1234-1234-123456789abc"),
    withContext = true,
    timeoutSeconds = 30
};

var response = await client.PostAsJsonAsync(
    "https://your-api.com/api/ScriptsController/Execute",
    request);

var result = await response.Content.ReadFromJsonAsync<ExecutionResult>();

Error Scenarios

Error HTTP Status Description
Script Not Found 404 The specified scriptId does not exist
Script Not Compiled 400 The script must be compiled before execution
Execution Timeout 400 Script exceeded the timeout limit
Execution Failed 400 Script threw an exception during execution
Server Error 500 Internal server error

Security Recommendations

Remote script execution can pose security risks. Follow these best practices:

  1. Use ApiKey Authentication: Implement Xeku.ApiKey module for external API access
  2. Limit Script Permissions: Use XAF security to restrict who can create/edit scripts
  3. Set Reasonable Timeouts: Default 30 seconds prevents infinite loops
  4. Monitor Execution Logs: Review ScriptExecutionLog regularly
  5. Validate Script Content: Review scripts before compilation in production

Performance Considerations

  • Assembly Caching: Compiled assemblies are cached in memory for fast execution
  • Async Execution: The Execute endpoint is fully async-compatible
  • Timeout Mechanism: Uses CancellationTokenSource for efficient timeout handling

License

Proprietary - Xeku Solutions

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.0.7 95 1/28/2026