fix: link clicks empty array validation

This commit is contained in:
Juan Rodriguez
2024-07-12 18:59:46 +02:00
parent cebbd48237
commit 8f33375b5f
5 changed files with 8 additions and 7 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
FROM alpine:edge as base
WORKDIR /usr/src/app
RUN apk update && apk add --no-cache \
@@ -19,8 +20,8 @@ RUN shards build --progress
FROM base AS release
RUN mkdir -p /usr/src/app/sqlite
COPY --from=build /usr/src/app/db db
COPY --from=build /usr/src/app/data data
COPY --from=build /usr/src/app/bin /usr/local/bin
COPY --from=build /usr/src/app/data /usr/local/data
EXPOSE 4000/tcp
CMD ["bit"]
+1 -3
View File
@@ -1,6 +1,4 @@
# bit
> Lightning fast, lightweight and minimal self-hosted url shortener
`latest` tag is unstable (Under development!)
## Benchmark
+1 -1
View File
@@ -4,7 +4,7 @@ module App
before_all do |env|
env.response.headers["Access-Control-Allow-Origin"] = "*"
env.response.headers["Access-Control-Allow-Methods"] = "GET, POST, PUT, DELETE, OPTIONS"
env.response.headers["Access-Control-Allow-Headers"] = "Content-Type, Accept, X-Api-Key"
env.response.headers["Access-Control-Allow-Headers"] = "Content-Type, Accept, Origin, X-Api-Key"
end
after_all do |env|
+1 -1
View File
@@ -16,7 +16,7 @@ module App::Serializers
builder.field("id", @link.id)
builder.field("refer", @refer)
builder.field("origin", @link.url)
builder.field("clicks", @link.clicks.map { |click| App::Serializers::Click.new(click) })
builder.field("clicks", @link.clicks.try(&.map { |click| App::Serializers::Click.new(click) }) || [] of App::Serializers::Click)
end
end
end
+3 -1
View File
@@ -67,8 +67,8 @@ function measure {
--header "X-Api-Key: $api_key" \
--header "Content-Type: application/json" \
--data "{ \"url\": \"https://kagi.com\" }")
refer=$(echo $response | awk -F'"' '/"refer":/{print $(NF-1)}')
if [[ -n $refer ]]; then
refer_links+=("$refer")
if (( i % 100 == 0 )); then
@@ -76,6 +76,8 @@ function measure {
fi
else
echo "Failed to create short link $i"
echo $response
exit 1
fi
done