File tree Expand file tree Collapse file tree 4 files changed +10
-8
lines changed
Expand file tree Collapse file tree 4 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ services:
3737 environment :
3838 PG_URI : ' postgresql://default:password@postgres:5432/postgres'
3939 AUTH : dev
40+ JWT : dev-jwt-secret
4041 ports :
4142 - 3000:3000
4243 healthcheck :
Original file line number Diff line number Diff line change 1- import crypto from 'node:crypto' ;
21import process from 'node:process' ;
32
43import dotenv from 'dotenv' ;
@@ -33,8 +32,8 @@ export function useConfig(): Config {
3332 }
3433
3534 if ( ! process . env . JWT ) {
36- console . log ( `JWT was not set, defaulting to a randomized byte hex string. `) ;
37- process . env . JWT = crypto . randomBytes ( 128 ) . toString ( 'hex' ) ;
35+ console . error ( `Failed to specify JWT, no JWT secret provided `) ;
36+ throw new Error ( `JWT must be set to a strong secret` ) ;
3837 }
3938
4039 if ( typeof process . env . JWT_STRICTNESS === 'undefined' ) {
@@ -50,8 +49,8 @@ export function useConfig(): Config {
5049 config = {
5150 PORT : process . env . PORT ? Number . parseInt ( process . env . PORT ) : 3000 ,
5251 PG_URI : process . env . PG_URI ,
53- AUTH : process . env . AUTH ?? 'default' ,
54- JWT : process . env . JWT ?? 'default-secret-key' ,
52+ AUTH : process . env . AUTH as string ,
53+ JWT : process . env . JWT as string ,
5554 JWT_STRICTNESS : process . env . JWT_STRICTNESS as JWT_STRICTNESS ,
5655 DISCORD_WEBHOOK_URL : process . env . DISCORD_WEBHOOK_URL ,
5756 } ;
Original file line number Diff line number Diff line change @@ -11,5 +11,6 @@ services:
1111 BATCH_SIZE : 50
1212 MEMO_PREFIX : dither.
1313 RECEIVER : atone1uq6zjslvsa29cy6uu75y8txnl52mw06j6fzlep
14+ AUTH : dev
1415 # LOG: process.env.LOG === 'true' ? true : false,
1516 command : [pnpm, start]
Original file line number Diff line number Diff line change @@ -13,8 +13,9 @@ export function useConfig(): typeof config {
1313 return config ;
1414 }
1515
16- if ( typeof process . env . AUTH === 'undefined' ) {
17- console . warn ( `AUTH env variable is set to default, ensure you provide an authorization key for reader communication` ) ;
16+ if ( ! process . env . AUTH || process . env . AUTH === 'default' ) {
17+ console . error ( `Failed to specify AUTH, no authorization secret provided` ) ;
18+ throw new Error ( `AUTH must be set to a strong secret` ) ;
1819 }
1920
2021 config = {
@@ -25,7 +26,7 @@ export function useConfig(): typeof config {
2526 RECEIVER : process . env . RECEIVER ,
2627 SENDER : process . env . SENDER ,
2728 LOG : process . env . LOG === 'true' ,
28- AUTH : process . env . AUTH ?? 'default' ,
29+ AUTH : process . env . AUTH ,
2930
3031 ECLESIA_GRAPHQL_ENDPOINT : process . env . ECLESIA_GRAPHQL_ENDPOINT ,
3132 ECLESIA_GRAPHQL_SECRET : process . env . ECLESIA_GRAPHQL_SECRET ,
You can’t perform that action at this time.
0 commit comments