Skip to content

FluxbaseAdminFunctions

Admin Functions manager for managing edge functions Provides create, update, delete, and bulk sync operations

new FluxbaseAdminFunctions(fetch): FluxbaseAdminFunctions

ParameterType
fetchFluxbaseFetch

FluxbaseAdminFunctions

create(request): Promise<object>

Create a new edge function

ParameterTypeDescription
requestCreateFunctionRequestFunction configuration and code

Promise<object>

Promise resolving to { data, error } tuple with created function metadata

NameType
datanull | EdgeFunction
errornull | Error
const { data, error } = await client.admin.functions.create({
name: 'my-function',
code: 'export default async function handler(req) { return { hello: "world" } }',
enabled: true
})

delete(name): Promise<object>

Delete an edge function

ParameterTypeDescription
namestringFunction name

Promise<object>

Promise resolving to { data, error } tuple

NameType
datanull
errornull | Error
const { data, error } = await client.admin.functions.delete('my-function')

get(name): Promise<object>

Get details of a specific edge function

ParameterTypeDescription
namestringFunction name

Promise<object>

Promise resolving to { data, error } tuple with function metadata

NameType
datanull | EdgeFunction
errornull | Error
const { data, error } = await client.admin.functions.get('my-function')
if (data) {
console.log('Function version:', data.version)
}

getExecutions(name, limit?): Promise<object>

Get execution history for an edge function

ParameterTypeDescription
namestringFunction name
limit?numberMaximum number of executions to return (optional)

Promise<object>

Promise resolving to { data, error } tuple with execution records

NameType
datanull | EdgeFunctionExecution[]
errornull | Error
const { data, error } = await client.admin.functions.getExecutions('my-function', 10)
if (data) {
data.forEach(exec => {
console.log(`${exec.executed_at}: ${exec.status} (${exec.duration_ms}ms)`)
})
}

list(namespace?): Promise<object>

List all edge functions (admin view)

ParameterTypeDescription
namespace?stringOptional namespace filter (if not provided, lists all public functions)

Promise<object>

Promise resolving to { data, error } tuple with array of functions

NameType
datanull | EdgeFunction[]
errornull | Error
// List all public functions
const { data, error } = await client.admin.functions.list()
// List functions in a specific namespace
const { data, error } = await client.admin.functions.list('my-namespace')
if (data) {
console.log('Functions:', data.map(f => f.name))
}

listNamespaces(): Promise<object>

List all namespaces that have edge functions

Promise<object>

Promise resolving to { data, error } tuple with array of namespace strings

NameType
datanull | string[]
errornull | Error
const { data, error } = await client.admin.functions.listNamespaces()
if (data) {
console.log('Available namespaces:', data)
}

sync(options): Promise<object>

Sync multiple functions to a namespace

Bulk create/update/delete functions in a specific namespace. This is useful for deploying functions from your application to Fluxbase in Kubernetes or other container environments.

Requires service_role or admin authentication.

ParameterTypeDescription
optionsSyncFunctionsOptionsSync configuration including namespace, functions, and options

Promise<object>

Promise resolving to { data, error } tuple with sync results

NameType
datanull | SyncFunctionsResult
errornull | Error
// Sync functions to "payment-service" namespace
const { data, error } = await client.admin.functions.sync({
namespace: 'payment-service',
functions: [
{
name: 'process-payment',
code: 'export default async function handler(req) { ... }',
enabled: true,
allow_net: true
},
{
name: 'refund-payment',
code: 'export default async function handler(req) { ... }',
enabled: true
}
],
options: {
delete_missing: true // Remove functions not in this list
}
})
if (data) {
console.log(`Synced: ${data.summary.created} created, ${data.summary.updated} updated`)
}
// Dry run to preview changes
const { data, error } = await client.admin.functions.sync({
namespace: 'myapp',
functions: [...],
options: { dry_run: true }
})

update(name, updates): Promise<object>

Update an existing edge function

ParameterTypeDescription
namestringFunction name
updatesUpdateFunctionRequestFields to update

Promise<object>

Promise resolving to { data, error } tuple with updated function metadata

NameType
datanull | EdgeFunction
errornull | Error
const { data, error } = await client.admin.functions.update('my-function', {
enabled: false,
description: 'Updated description'
})