feat: notes-python CRUD example + runtime path/query forwarding

- invoke.go: forward sub-path and query string to function pods
- server.js v0.1.2: add _path, _query, _method to event
- server.py v0.1.1: add _path, _query, _method to event
- upload.go: bump runtime versions (nodejs20:v0.1.2, python3.11:v0.1.1)
- examples/notes-python: CRUD notes via sub-path routing
  - sql-runner: generic SQL executor for DDL jobs
  - notes: CRUD router (/add, /update, /delete)
  - notes-list: SELECT all notes
  - init.tf: create TABLE + INDEX on apply
This commit is contained in:
“Naeel”
2026-03-09 09:51:56 +04:00
parent 0066d9c0f9
commit 88a0fb9db6
20 changed files with 344 additions and 11 deletions
+13 -1
View File
@@ -1,4 +1,4 @@
// Изменено: 2026-03-08
// Изменено: 2026-03-09
// HTTP-обёртка для serverless функций на Node.js 20.
// Загружает модуль из SLESS_ENTRYPOINT или handler.js по умолчанию.
// Формат SLESS_ENTRYPOINT: "module-name.functionName" (например: handler-http.handle)
@@ -51,6 +51,18 @@ const server = http.createServer(async (req, res) => {
}
}
// Добавляем метаданные запроса: путь, query params, метод.
// _path/_query/_method — зарезервированные поля, не конфликтуют с бизнес-полями.
// Позволяет роутить внутри одной функции: event._path === '/add'
const urlObj = new URL(req.url, 'http://localhost');
const query = {};
urlObj.searchParams.forEach((v, k) => { query[k] = v; });
if (typeof event === 'object' && !Array.isArray(event)) {
event._path = urlObj.pathname;
event._query = query;
event._method = req.method;
}
try {
const result = await userHandle(event);
sendJSON(res, 200, result);