Skip to content

Commit c0dac9a

Browse files
Refactor authentication and protocol version handling to use request body directly
1 parent 7e9bc8a commit c0dac9a

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

packages/react-on-rails-pro-node-renderer/src/worker/authHandler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ import { timingSafeEqual } from 'crypto';
1010
import type { FastifyRequest } from './types.js';
1111
import { getConfig } from '../shared/configBuilder.js';
1212

13-
export default function authenticate(req: FastifyRequest) {
13+
export interface AuthBody {
14+
password?: string;
15+
}
16+
17+
export function authenticate(body: AuthBody) {
1418
const { password } = getConfig();
1519

1620
if (password) {
17-
const reqPassword = (req.body as { password?: string }).password || '';
21+
const reqPassword = body.password || '';
1822

1923
// Use timing-safe comparison to prevent timing attacks
2024
// Both strings must be converted to buffers of the same length

packages/react-on-rails-pro-node-renderer/src/worker/checkProtocolVersionHandler.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,8 @@ export interface RequestBody {
4040
railsEnv?: string;
4141
}
4242

43-
<<<<<<< HEAD:packages/react-on-rails-pro-node-renderer/src/worker/checkProtocolVersionHandler.ts
44-
export default function checkProtocolVersion(req: FastifyRequest) {
45-
const { protocolVersion: reqProtocolVersion, gemVersion, railsEnv } = req.body as RequestBody;
46-
=======
4743
export function checkProtocolVersion(body: RequestBody) {
4844
const { protocolVersion: reqProtocolVersion, gemVersion, railsEnv } = body;
49-
>>>>>>> 7b1608e57 (Refactor request handling by consolidating prechecks):react_on_rails_pro/packages/node-renderer/src/worker/checkProtocolVersionHandler.ts
5045

5146
// Check protocol version
5247
if (reqProtocolVersion !== packageJson.protocolVersion) {

packages/react-on-rails-pro-node-renderer/src/worker/vm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export async function buildExecutionContext(
376376
return result;
377377
} catch (exception) {
378378
const exceptionMessage = formatExceptionMessage(renderingRequest, exception);
379-
log.debug('Caught exception in rendering request', exceptionMessage);
379+
log.debug('Caught exception in rendering request: %s', exceptionMessage);
380380
return Promise.resolve({ exceptionMessage });
381381
}
382382
};

0 commit comments

Comments
 (0)