2.5.5 • Published 1 year ago

yandex-cloud-fn v2.5.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

yandex-cloud-fn

Runtime-хелперы для Node.js функций в Yandex Cloud.

Что включает

  • покрытие типами: event, context, итд
  • определение источника запроса: isHttpRequest, isTimerRequest, итд
  • получение тела запроса (с учетом base64): getHttpBody
  • отправка json ответа: sendJson
  • корректное логирование: fixConsoleForLogging, fixValueForLogging.

Установка

npm i yandex-cloud-fn

Использование

import { Handler, HttpRequest, TimerRequest, isHttpRequest, sendJson } from 'yandex-cloud-fn';

export const handler: Handler<HttpRequest | TimerRequest> = async event => {
  if (isHttpRequest(event)) {
    const reqBody = JSON.parse(getHttpBody(event));
    console.log(`Triggered by http request: ${JSON.stringify(reqBody)}`);
    return sendJson({ ok: true });
  } else {
    console.log(`Triggered by timer: ${event.messages[0].details.trigger_id}`);
  }
}

Больше примеров в папке /examples.

Доступные методы

tbd

Лицензия

MIT @ Vitaliy Potapov

2.5.5

1 year ago

2.5.2

1 year ago

2.5.4

1 year ago

2.5.3

1 year ago

2.5.0

2 years ago

2.5.1

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.1.1

2 years ago

2.4.0

2 years ago

2.1.0

2 years ago

2.0.0

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago