Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
79 lines
3.2 KiB
JavaScript
79 lines
3.2 KiB
JavaScript
import { Server } from '@hocuspocus/server'
|
|
import { Redis } from '@hocuspocus/extension-redis'
|
|
import { Logger } from '@hocuspocus/extension-logger'
|
|
import { NotificationExtension } from './NotificationExtension.js'
|
|
import { TicketUpdatesExtension } from './TicketUpdatesExtension.js'
|
|
import { AiParticipantExtension } from './AiParticipantExtension.js'
|
|
import { CollabPersistenceExtension } from './CollabPersistenceExtension.js'
|
|
import { validateDocumentRoomAccess } from './tenantValidation.js'
|
|
|
|
// Helper function to get required env var or fail in production
|
|
function getEnvOrFail(key, fallbackValue = null) {
|
|
const value = process.env[key];
|
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
|
|
if (!value && isProduction) {
|
|
console.error(`ERROR: Required environment variable ${key} is not set in production mode`);
|
|
process.exit(1);
|
|
}
|
|
|
|
return value || fallbackValue;
|
|
}
|
|
|
|
const server = Server.configure({
|
|
port: process.env.PORT || 1234,
|
|
// Coalesce onStoreDocument: persist ~2s after the last edit, and force a
|
|
// flush at most every 15s during continuous editing. Hocuspocus also fires
|
|
// onStoreDocument when the last client disconnects.
|
|
debounce: Number(process.env.COLLAB_PERSIST_DEBOUNCE_MS || 2000),
|
|
maxDebounce: Number(process.env.COLLAB_PERSIST_MAX_DEBOUNCE_MS || 15000),
|
|
extensions: [
|
|
// redisExtension,
|
|
new Redis({
|
|
host: process.env.REDIS_HOST || 'localhost',
|
|
port: process.env.REDIS_PORT || 6379,
|
|
options: {
|
|
username: process.env.REDIS_USERNAME || 'default',
|
|
password: getEnvOrFail('REDIS_PASSWORD', 'sebastian123')
|
|
},
|
|
}),
|
|
new CollabPersistenceExtension({
|
|
apiUrl: process.env.COLLAB_PERSIST_API_URL || 'http://localhost:3000/api/internal/collab/persist',
|
|
apiKey: process.env.COLLAB_PERSIST_API_KEY || '',
|
|
}),
|
|
new NotificationExtension({
|
|
redisHost: process.env.REDIS_HOST || 'localhost',
|
|
redisPort: process.env.REDIS_PORT || 6379,
|
|
redisUsername: process.env.REDIS_USERNAME || 'default',
|
|
redisPassword: getEnvOrFail('REDIS_PASSWORD', 'sebastian123'),
|
|
redisPrefix: process.env.REDIS_PREFIX || 'alga-psa:'
|
|
}),
|
|
new TicketUpdatesExtension({
|
|
redisHost: process.env.REDIS_HOST || 'localhost',
|
|
redisPort: process.env.REDIS_PORT || 6379,
|
|
redisUsername: process.env.REDIS_USERNAME || 'default',
|
|
redisPassword: getEnvOrFail('REDIS_PASSWORD', 'sebastian123'),
|
|
redisPrefix: process.env.REDIS_PREFIX || 'alga-psa:'
|
|
}),
|
|
new AiParticipantExtension({
|
|
aiApiUrl: process.env.AI_DOCUMENT_API_URL || 'http://localhost:3000/api/v1/ai/document-assist',
|
|
aiApiKey: process.env.AI_DOCUMENT_API_KEY || '',
|
|
}),
|
|
new Logger({
|
|
level: 'debug', // Set to 'debug' for maximum verbosity
|
|
}),
|
|
],
|
|
async onConnect(data) {
|
|
validateDocumentRoomAccess(data.documentName, data.request);
|
|
},
|
|
})
|
|
|
|
// const server = Server.configure({
|
|
// port: 1234,
|
|
// extensions: [
|
|
// new Logger(),
|
|
// ],
|
|
// })
|
|
|
|
server.listen()
|