File tree Expand file tree Collapse file tree 3 files changed +24
-4
lines changed
Expand file tree Collapse file tree 3 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export default async function LocaleLayout({
3737 title : string ;
3838 } > = [ ] ;
3939
40+
4041 const enableAdmin =
4142 (
4243 process . env . ENABLE_ADMIN_API ??
Original file line number Diff line number Diff line change @@ -12,14 +12,29 @@ dotenv.config();
1212type AppDatabase = PgDatabase < PgQueryResultHKT , typeof schema > ;
1313
1414const APP_ENV = process . env . APP_ENV ?. trim ( ) . toLowerCase ( ) ;
15+
16+ if ( ! APP_ENV ) {
17+ throw new Error (
18+ '[db] APP_ENV is required. Set APP_ENV=local in .env for development, or APP_ENV=develop/production for deployment'
19+ ) ;
20+ }
21+
1522const IS_LOCAL_ENV = APP_ENV === 'local' ;
23+
24+ if ( process . env . NODE_ENV !== 'test' ) {
25+ console . log ( '[db] runtime env check' , {
26+ has_DATABASE_URL : Boolean ( process . env . DATABASE_URL ?. trim ( ) ) ,
27+ has_DATABASE_URL_LOCAL : Boolean ( process . env . DATABASE_URL_LOCAL ?. trim ( ) ) ,
28+ } ) ;
29+ }
30+
1631const STRICT_LOCAL_DB_GUARD = process . env . SHOP_STRICT_LOCAL_DB === '1' ;
1732const REQUIRED_LOCAL_DB_URL = process . env . SHOP_REQUIRED_DATABASE_URL_LOCAL ;
1833
1934if ( STRICT_LOCAL_DB_GUARD ) {
2035 if ( ! IS_LOCAL_ENV ) {
2136 throw new Error (
22- `[db] SHOP_STRICT_LOCAL_DB=1 requires APP_ENV=local (got "${ APP_ENV ?? 'undefined' } ")`
37+ `[db] SHOP_STRICT_LOCAL_DB=1 requires APP_ENV=local (got "${ APP_ENV } ")`
2338 ) ;
2439 }
2540
@@ -68,7 +83,7 @@ if (IS_LOCAL_ENV) {
6883
6984 if ( ! url ) {
7085 throw new Error (
71- `[db] APP_ENV=${ APP_ENV ?? 'undefined' } requires DATABASE_URL to be set`
86+ `[db] APP_ENV=${ APP_ENV } requires DATABASE_URL to be set`
7287 ) ;
7388 }
7489
Original file line number Diff line number Diff line change @@ -20,13 +20,17 @@ export async function getAdminCategoryList(): Promise<AdminCategoryItem[]> {
2020 title : categoryTranslations . title ,
2121 } )
2222 . from ( categories )
23- . innerJoin (
23+ . leftJoin (
2424 categoryTranslations ,
2525 sql `${ categoryTranslations . categoryId } = ${ categories . id } AND ${ categoryTranslations . locale } = ${ ADMIN_LOCALE } `
2626 )
2727 . orderBy ( categories . displayOrder ) ;
2828
29- return rows ;
29+ return rows . map ( row => ( {
30+ id : row . id ,
31+ slug : row . slug ,
32+ title : row . title ?? row . slug ,
33+ } ) ) ;
3034}
3135
3236export async function getMaxQuizDisplayOrder (
You can’t perform that action at this time.
0 commit comments