Add support to switch between deno and nodejs function executor
This commit is contained in:
@@ -105,8 +105,7 @@ http = Blueprint('http', __name__)
|
||||
@login_required
|
||||
def overview():
|
||||
user_id = current_user.id
|
||||
http_functions = db.execute(
|
||||
'SELECT id, user_id, NAME, script_content, invoked_count, environment_info, is_public, log_request, log_response, version_number FROM http_functions WHERE user_id=%s ORDER by id DESC', [user_id])
|
||||
http_functions = db.get_http_functions_for_user(user_id)
|
||||
http_functions = create_http_functions_view_model(http_functions)
|
||||
if htmx:
|
||||
return render_block(environment, "dashboard/http_functions/overview.html", "page", http_functions=http_functions)
|
||||
@@ -128,12 +127,9 @@ def new():
|
||||
is_public = request.json.get('is_public')
|
||||
log_request = request.json.get('log_request')
|
||||
log_response = request.json.get('log_response')
|
||||
runtime = request.json.get('runtime', 'node')
|
||||
|
||||
db.execute(
|
||||
'INSERT INTO http_functions (user_id, NAME, script_content, environment_info, is_public, log_request, log_response) VALUES (%s, %s, %s, %s, %s, %s, %s)',
|
||||
[user_id, name, script_content, environment_info, is_public, log_request, log_response],
|
||||
commit=True
|
||||
)
|
||||
db.create_new_http_function(user_id, name, script_content, environment_info, is_public, log_request, log_response, runtime)
|
||||
|
||||
return jsonify({
|
||||
"status": "success",
|
||||
@@ -155,12 +151,9 @@ def edit(function_id):
|
||||
is_public = request.json.get('is_public')
|
||||
log_request = request.json.get('log_request')
|
||||
log_response = request.json.get('log_response')
|
||||
runtime = request.json.get('runtime', 'node')
|
||||
|
||||
updated_version = db.execute(
|
||||
'UPDATE http_functions SET NAME=%s, script_content=%s, environment_info=%s, is_public=%s, log_request=%s, log_response=%s WHERE user_id=%s AND id=%s RETURNING version_number',
|
||||
[name, script_content, environment_info, is_public, log_request, log_response, user_id, function_id],
|
||||
commit=True, one=True
|
||||
)
|
||||
updated_version = db.edit_http_function(user_id, function_id, name, script_content, environment_info, is_public, log_request, log_response, runtime)
|
||||
|
||||
return { "status": "success", "message": f'{name} updated' }
|
||||
except Exception as e:
|
||||
@@ -184,9 +177,7 @@ def delete(function_id):
|
||||
@login_required
|
||||
def logs(function_id):
|
||||
user_id = current_user.id
|
||||
http_function = db.execute(
|
||||
'SELECT id, user_id, NAME, script_content, invoked_count, environment_info, is_public, log_request, log_response, version_number, created_at FROM http_functions WHERE user_id=%s AND id=%s',
|
||||
[user_id, function_id], one=True)
|
||||
http_function = db.get_http_function_by_id(user_id, function_id)
|
||||
if not http_function:
|
||||
return jsonify({'error': 'Function not found'}), 404
|
||||
name = http_function['name']
|
||||
@@ -199,9 +190,7 @@ def logs(function_id):
|
||||
@login_required
|
||||
def client(function_id):
|
||||
user_id = current_user.id
|
||||
http_function = db.execute(
|
||||
'SELECT id, user_id, NAME, script_content, invoked_count, environment_info, is_public, log_request, log_response, version_number, created_at FROM http_functions WHERE user_id=%s AND id=%s',
|
||||
[user_id, function_id], one=True)
|
||||
http_function = db.get_http_function_by_id(user_id, function_id)
|
||||
if not http_function:
|
||||
return jsonify({'error': 'Function not found'}), 404
|
||||
|
||||
@@ -265,6 +254,7 @@ def editor(function_id):
|
||||
'log_request': http_function['log_request'],
|
||||
'log_response': http_function['log_response'],
|
||||
'version_number': http_function['version_number'],
|
||||
'runtime': http_function.get('runtime', 'node'),
|
||||
'user_id': user_id,
|
||||
'function_id': function_id,
|
||||
# Add new URLs for navigation
|
||||
|
||||
Reference in New Issue
Block a user