Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions frontend/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@ type AppDatabase = PgDatabase<PgQueryResultHKT, typeof schema>;

const APP_ENV = process.env.APP_ENV?.trim().toLowerCase();

if (!APP_ENV) {
throw new Error(
'[db] APP_ENV is required. Set APP_ENV=local in .env for development, or APP_ENV=develop/production for deployment'
);
}

const IS_LOCAL_ENV = APP_ENV === 'local';

if (process.env.NODE_ENV !== 'test') {
console.log('[db] runtime env check', {
APP_ENV: process.env.APP_ENV ?? '<undefined>',
has_DATABASE_URL: Boolean(process.env.DATABASE_URL?.trim()),
has_DATABASE_URL_LOCAL: Boolean(process.env.DATABASE_URL_LOCAL?.trim()),
NETLIFY: process.env.NETLIFY ?? '<undefined>',
CONTEXT: process.env.CONTEXT ?? '<undefined>',
NODE_ENV: process.env.NODE_ENV ?? '<undefined>',
});
}

const IS_LOCAL_ENV = APP_ENV === 'local';

const STRICT_LOCAL_DB_GUARD = process.env.SHOP_STRICT_LOCAL_DB === '1';
const REQUIRED_LOCAL_DB_URL = process.env.SHOP_REQUIRED_DATABASE_URL_LOCAL;

Expand Down
2 changes: 1 addition & 1 deletion frontend/db/queries/categories/admin-categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function getAdminCategoryList(): Promise<AdminCategoryItem[]> {
return rows.map(row => ({
id: row.id,
slug: row.slug,
title: row.title ?? row.slug,
title: row.title?.trim() || row.slug
}));
}

Expand Down
4 changes: 4 additions & 0 deletions frontend/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import createNextIntlPlugin from 'next-intl/plugin';
const withNextIntl = createNextIntlPlugin('./i18n/request.ts');

const nextConfig: NextConfig = {
env: {
APP_ENV: process.env.APP_ENV,
DATABASE_URL: process.env.DATABASE_URL,
},
images: {
remotePatterns: [
{
Expand Down
3 changes: 3 additions & 0 deletions frontend/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export default defineConfig({
},
},
test: {
env: {
APP_ENV: 'local',
},
environment: 'node',
include: [
'lib/tests/**/*.test.ts',
Expand Down
3 changes: 3 additions & 0 deletions frontend/vitest.shop.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export default defineConfig({
},
},
test: {
env: {
APP_ENV: 'local',
},
environment: 'node',
include: ['lib/tests/shop/**/*.test.ts'],
globals: true,
Expand Down
3 changes: 0 additions & 3 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
command = "npm ci --include=optional && npm run build"
publish = ".next"

[functions]
node_bundler = "esbuild"

[build.environment]
NODE_VERSION = "20.19.0"

Expand Down
Loading