fix: add the redis extension conditionally (#5524)
* fix: add the redis extension conditionally * chore: import order and stuff * fix: added logger, error handling and routing * feat: configured sentry with source maps * fix: sentry config and returning json * fix: remove on change logs * fix: add pretty print
This commit is contained in:
parent
406ffcd7de
commit
e1380f52ec
12 changed files with 644 additions and 212 deletions
35
live/src/core/hocuspocus-server.ts
Normal file
35
live/src/core/hocuspocus-server.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { Server } from "@hocuspocus/server";
|
||||
|
||||
import { handleAuthentication } from "@/core/lib/authentication.js";
|
||||
import { getExtensions } from "@/core/extensions/index.js";
|
||||
|
||||
export const HocusPocusServer = Server.configure({
|
||||
onAuthenticate: async ({
|
||||
requestHeaders,
|
||||
requestParameters,
|
||||
connection,
|
||||
// user id used as token for authentication
|
||||
token,
|
||||
}) => {
|
||||
// request headers
|
||||
const cookie = requestHeaders.cookie?.toString();
|
||||
// params
|
||||
const params = requestParameters;
|
||||
|
||||
if (!cookie) {
|
||||
throw Error("Credentials not provided");
|
||||
}
|
||||
|
||||
try {
|
||||
await handleAuthentication({
|
||||
connection,
|
||||
cookie,
|
||||
params,
|
||||
token,
|
||||
});
|
||||
} catch (error) {
|
||||
throw Error("Authentication unsuccessful!");
|
||||
}
|
||||
},
|
||||
extensions: getExtensions(),
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue