File tree Expand file tree Collapse file tree 4 files changed +33
-16
lines changed
Expand file tree Collapse file tree 4 files changed +33
-16
lines changed Original file line number Diff line number Diff line change 11---
22export const prerender = false ;
33import Icon from ' @components/Icon.astro' ;
4-
5- const mode = process .env .MODE || import .meta .env .MODE ;
6-
7- // Only for development mode, to ease testing
8- if (mode == ' production' ) {
9- return ;
10- }
114---
125
136<div class =" footer-signup" >
Original file line number Diff line number Diff line change @@ -6,10 +6,10 @@ import type {
66 IDToken ,
77} from 'openid-client' ;
88
9- const server = import . meta . env . AUTH_OIDC_ISSUER || process . env . AUTH_OIDC_ISSUER ;
10- const clientId = import . meta . env . AUTH_OIDC_CLIENT_ID || process . env . AUTH_OIDC_CLIENT_ID ;
11- const clientSecret = import . meta . env . AUTH_OIDC_CLIENT_SECRET || process . env . AUTH_OIDC_CLIENT_SECRET ;
12- const redirect_uri = import . meta . env . AUTH_OIDC_REDIRECT_URI || process . env . AUTH_OIDC_REDIRECT_URI ;
9+ const server = process . env . AUTH_OIDC_ISSUER || import . meta . env . AUTH_OIDC_ISSUER ;
10+ const clientId = process . env . AUTH_OIDC_CLIENT_ID || import . meta . env . AUTH_OIDC_CLIENT_ID ;
11+ const clientSecret = process . env . AUTH_OIDC_CLIENT_SECRET || import . meta . env . AUTH_OIDC_CLIENT_SECRET ;
12+ const redirect_uri = process . env . AUTH_OIDC_REDIRECT_URI || import . meta . env . AUTH_OIDC_REDIRECT_URI ;
1313
1414export interface callbackResult {
1515 accessToken : string ;
Original file line number Diff line number Diff line change @@ -27,11 +27,11 @@ async function dbConnect() {
2727 if ( ! sql ) {
2828 const postgres = ( await import ( 'postgres' ) ) . default ;
2929
30- const USER = import . meta . env . POSTGRES_USER || process . env . POSTGRES_USER ;
31- const PASSWORD = import . meta . env . POSTGRES_PASSWORD || process . env . POSTGRES_PASSWORD ;
32- const HOST = import . meta . env . POSTGRES_HOST || process . env . POSTGRES_HOST ;
33- const PORT = import . meta . env . POSTGRES_PORT || process . env . POSTGRES_PORT || 5432 ;
34- const DB = import . meta . env . POSTGRES_DB || process . env . POSTGRES_DB ;
30+ const USER = 'datum-net' ;
31+ const PASSWORD = process . env . POSTGRES_PASSWORD || import . meta . env . POSTGRES_PASSWORD || '' ;
32+ const HOST = process . env . privateIP || import . meta . env . POSTGRES_HOST ;
33+ const PORT = process . env . POSTGRES_PORT || import . meta . env . POSTGRES_PORT || 5432 ;
34+ const DB = process . env . POSTGRES_DB || import . meta . env . POSTGRES_DB || 'datum-net' ;
3535 const connectionString = `postgres://${ USER } :${ PASSWORD } @${ HOST } :${ PORT } /${ DB } ` ;
3636
3737 if ( ! connectionString ) {
Original file line number Diff line number Diff line change 11---
22export const prerender = false ;
3+ import { dbConnect } from ' @libs/postgres' ;
34
45const mode = process .env .MODE || import .meta .env .MODE ;
56
@@ -8,9 +9,28 @@ if (mode == 'production') {
89 return ;
910}
1011
12+ /**
13+ * Database testing
14+ */
15+ let dbConnected = false ;
16+ try {
17+ const sql = await dbConnect ();
18+ const tables = await sql ` SHOW TABLES ` ;
19+ if (tables ) {
20+ dbConnected = true ;
21+ }
22+ } catch {
23+ dbConnected = false ;
24+ }
25+
1126type EnvValue = string | number | boolean | undefined ;
1227type EnvRecord = Record <string , EnvValue >;
1328
29+ /**
30+ * Filters out sensitive environment variables by masking their values.
31+ * Sensitive variables are identified by common keywords in their names
32+ * or if their values contain user-specific file paths.
33+ */
1434const filterSensitiveVars = (envVars : EnvRecord ): EnvRecord => {
1535 return Object .fromEntries (
1636 Object .entries (envVars ).map (([key , value ]) => {
@@ -70,7 +90,11 @@ const responseObj = {
7090 release: process .release ,
7191 uptime: process .uptime (),
7292 },
93+ database: {
94+ connected: dbConnected ,
95+ },
7396};
97+
7498return new Response (JSON .stringify (responseObj , null , 2 ), {
7599 status: 200 ,
76100 headers: {
You can’t perform that action at this time.
0 commit comments