feat: big-suite terraform example + provider nodejs zip fix
- examples/big-suite: E-Commerce 10 functions, 6 layers, real depends_on - provider: nodejs packages now wrapped in ESM zip (buildJSDeployZip) - provider: loadPackageLiteral reads raw file, nodejs zip via source_dir - all 10 functions verified working: python/node/ruby/go runtimes
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import json
|
||||
from flask import request
|
||||
|
||||
_DB = {
|
||||
"user-1": {"id": "user-1", "name": "Alice", "email": "alice@example.com", "tier": "gold", "orders": 42},
|
||||
"user-2": {"id": "user-2", "name": "Bob", "email": "bob@example.com", "tier": "silver", "orders": 11},
|
||||
"user-0": {"id": "user-0", "name": "Admin", "email": "admin@example.com", "tier": "admin", "orders": 0},
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
# Path variables не передаются в Fission функцию — используем query param ?id=
|
||||
user_id = request.args.get("id", "")
|
||||
|
||||
if not user_id or user_id not in _DB:
|
||||
return {
|
||||
"status": 404,
|
||||
"body": json.dumps({"error": "user not found", "id": user_id}),
|
||||
"headers": {"Content-Type": "application/json"},
|
||||
}
|
||||
|
||||
user = dict(_DB[user_id])
|
||||
user.pop("email", None)
|
||||
return json.dumps({"status": "ok", "user": user})
|
||||
|
||||
# Достаём id из query string или пути
|
||||
user_id = ""
|
||||
if hasattr(context, "request"):
|
||||
path = getattr(context.request, "url", "") or ""
|
||||
# /ecom/users/user-1 → user-1
|
||||
parts = [p for p in path.split("/") if p]
|
||||
if parts:
|
||||
user_id = parts[-1]
|
||||
qs = getattr(context.request, "query", {}) or {}
|
||||
if not user_id and "id" in qs:
|
||||
user_id = qs["id"]
|
||||
|
||||
if not user_id or user_id not in _DB:
|
||||
return {
|
||||
"status": 404,
|
||||
"body": json.dumps({"error": "user not found", "id": user_id}),
|
||||
"headers": {"Content-Type": "application/json"},
|
||||
}
|
||||
|
||||
user = dict(_DB[user_id])
|
||||
# Не возвращаем email в публичном ответе
|
||||
user.pop("email", None)
|
||||
return json.dumps({"status": "ok", "user": user})
|
||||
Reference in New Issue
Block a user