From 49b7156655b0cee76867f2beac61e17aab57de2b Mon Sep 17 00:00:00 2001 From: Kiko Beats Date: Sat, 17 Feb 2024 12:28:59 +0000 Subject: [PATCH] build: update dependencies --- fly.toml | 41 ++++++++++++++++------------------------- package.json | 27 +++++++++++++-------------- src/authentication.js | 2 ++ src/index.js | 1 + 4 files changed, 32 insertions(+), 39 deletions(-) diff --git a/fly.toml b/fly.toml index 1d1759a..ad74119 100644 --- a/fly.toml +++ b/fly.toml @@ -1,31 +1,22 @@ app = "unavatar" -kill_signal = "SIGINT" +kill_signal = "SIGTERM" kill_timeout = 5 -processes = [] -[experimental] - allowed_public_ports = [] - auto_rollback = true - -[[services]] - http_checks = [] +[http_service] internal_port = 3000 - processes = ["app"] - protocol = "tcp" - script_checks = [] - - # [services.concurrency] - # hard_limit = 8 - # soft_limit = 4 - # type = "requests" + force_https = false + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 - [[services.ports]] - force_https = false - handlers = ["http"] - port = 80 +[http_service.concurrency] + type = "requests" + soft_limit = 5 + hard_limit = 10 - [[services.tcp_checks]] - grace_period = "1s" - interval = "15s" - restart_limit = 0 - timeout = "2s" +[[http_service.checks]] + grace_period = "3s" + interval = "30s" + method = "GET" + timeout = "1s" + path = "/ping" diff --git a/package.json b/package.json index cabcbf5..08de8db 100644 --- a/package.json +++ b/package.json @@ -91,29 +91,29 @@ "@keyvhq/core": "~2.1.0", "@keyvhq/multi": "~2.1.0", "@keyvhq/redis": "~2.1.0", - "@kikobeats/time-span": "~1.0.3", + "@kikobeats/time-span": "~1.0.4", "@microlink/mql": "~0.12.2", - "@microlink/ping-url": "~1.4.11", - "@microlink/ua": "~1.2.0", - "async-memoize-one": "~1.1.6", - "browserless": "~10.2.4", + "@microlink/ping-url": "~1.4.12", + "@microlink/ua": "~1.2.3", + "async-memoize-one": "~1.1.7", + "browserless": "~10.2.6", "cacheable-lookup": "~6.1.0", - "cacheable-response": "~2.8.10", + "cacheable-response": "~2.8.12", "cheerio": "~1.0.0-rc.12", "cors": "~2.8.5", "data-uri-regex": "~0.1.4", "data-uri-to-buffer": "~5.0.1", - "debug-logfmt": "~1.2.0", + "debug-logfmt": "~1.2.2", "frequency-counter": "~1.0.1", "got": "~11.8.6", "helmet": "~7.1.0", - "html-get": "~2.15.0", - "http-compression": "~1.0.17", + "html-get": "~2.15.1", + "http-compression": "~1.0.19", "https-tls": "~1.0.16", "ioredis": "~5.3.2", "is-absolute-url": "~3.0.3", "is-email-like": "~1.0.0", - "is-url-http": "~2.3.7", + "is-url-http": "~2.3.8", "lodash": "~4.17.21", "ms": "~2.1.3", "on-finished": "~2.4.1", @@ -124,13 +124,13 @@ "puppeteer": "~21.10.0", "qsm": "~2.1.2", "rate-limiter-flexible": "~5.0.0", - "router-http": "~1.0.5", + "router-http": "~1.0.7", "send-http": "~1.0.6", "serve-static": "~1.15.0", "srcset": "~4.0.0", "tangerine": "~1.5.4", - "top-crawler-agents": "~1.0.23", - "top-user-agents": "~2.1.0", + "top-crawler-agents": "~1.0.26", + "top-user-agents": "~2.1.10", "unique-random-array": "~2.0.0", "url-regex": "~5.0.0" }, @@ -172,7 +172,6 @@ "build": "gulp build && untracked > .vercelignore", "clean": "rm -rf node_modules", "contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true", - "deploy": "now -e NODE_ENV=production --public && now alias && now rm unavatar --safe --yes", "dev": "TZ=UTC watchexec --clear=clear --on-busy-update=restart 'fkill \"Google Chrome for Testing\" --silent && node src/server.js'", "dev:docker": "docker build --platform linux/amd64 -t unavatar . && docker run --platform linux/amd64 --name unavatar -e NODE_ENV=staging -p 3000:3000 --rm unavatar", "dev:docs": "concurrently \"npm run dev:docs:server\" \"npm run dev:docs:src\"", diff --git a/src/authentication.js b/src/authentication.js index 25b3b3f..391af58 100644 --- a/src/authentication.js +++ b/src/authentication.js @@ -5,6 +5,7 @@ const debug = require('debug-logfmt')('unavatar:authentication') const { RateLimiterMemory } = require('rate-limiter-flexible') const FrequencyCounter = require('frequency-counter') const onFinished = require('on-finished') +const os = require('os') const duration = timeSpan() const reqsMin = new FrequencyCounter(60) @@ -62,6 +63,7 @@ module.exports = async (req, res, next) => { debug(req.ipAddress, { uptime: duration(), + load: os.loadavg().map(n => n.toFixed(2)), reqs, 'req/m': perMinute, 'req/s': perSecond, diff --git a/src/index.js b/src/index.js index 610b910..82256ee 100644 --- a/src/index.js +++ b/src/index.js @@ -78,6 +78,7 @@ router next() } ) + .get('ping', (_, res) => send(res, 200, 'pong')) .get('/:key', (req, res) => ssrCache({ req,