Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
if: contains(github.event.pull_request.labels.*.name, 'ci:deployable')

runs-on: ubuntu-latest
environment: ${{ needs.namer.outputs.branch == 'staging' && github.actor == github.triggering_actor && 'staging' || 'manual-staging' }}
environment: manual-staging

env:
pull_image: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_USERNAME }}:${{ needs.namer.outputs.tag }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:

jobs:
prepare:
if: github.triggering_actor == 'niqzart'
if: github.triggering_actor == 'niqzart' || github.triggering_actor == 'unknownproperty'
uses: ./.github/workflows/common-work.yml
with:
tag: hocus-main
base-tag: hocus-staging
secrets: inherit

deploy_production:
if: github.triggering_actor == 'niqzart'
if: github.triggering_actor == 'niqzart' || github.triggering_actor == 'unknownproperty'
needs: prepare
runs-on: ubuntu-latest
environment: production
Expand Down
4 changes: 2 additions & 2 deletions src/common/fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { logServerError } from "./errors"

const back2BaseUrl = process.env.BACK_2_BASE_URL || "http://localhost:5000"
const back2BaseUrl = process.env.BACK_2__BASE_URL || "http://localhost:5000"
const back2BasePath = "/internal/storage-service/v2"
const back2ApiKey = process.env.BACK_2_API_KEY || "local"
const back2ApiKey = process.env.BACK_2__API_KEY || "local"

export async function fetchStorage(path: string, init?: RequestInit): Promise<Response | undefined> {
try {
Expand Down
23 changes: 5 additions & 18 deletions src/hooks/download.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fetchPayload } from "@hocuspocus/server"

import { HocusPocusError, logServerError } from "../common/errors"
import { HocusPocusError } from "../common/errors"
import { fetchStorageSafely } from "../common/fetcher"

export async function downloadYDocContent({ documentName }: fetchPayload): Promise<Uint8Array | null> {
Expand All @@ -11,24 +11,11 @@ export async function downloadYDocContent({ documentName }: fetchPayload): Promi
throw new HocusPocusError()
}

if (response.headers.get("content-length") === "0") {
const arrayBuffer = await response.arrayBuffer()

if (!arrayBuffer || arrayBuffer.byteLength === 0) {
return null
}

const responseBody = response.body
if (!responseBody) {
logServerError("Download: body is not present")
throw new HocusPocusError()
}
const data = await response.body.getReader().read()
if (!data) {
logServerError("Download: body read failed")
throw new HocusPocusError()
}
const result = data.value
if (!result) {
logServerError("Download: body value is empty")
throw new HocusPocusError()
}
return result
return new Uint8Array(arrayBuffer)
}
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ const server = Server.configure({
quiet: true,
onAuthenticate: verifyYDocAccess,
extensions: [
new Logger(),
new Logger(
{
onChange: process.env.ENABLE_CHANGE_LOGS === "true",
}
),
new Database({
fetch: downloadYDocContent,
store: storeYDocContent,
Expand Down
Loading