Skip to content

Commit

Permalink
Added logs
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidOkulski committed Jan 8, 2025
1 parent ff50495 commit f37cf58
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
30 changes: 28 additions & 2 deletions app/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,28 @@ const formRoutes = require('./formRoutes');
const { protectedRoute } = require('@bcgov/citz-imb-sso-express');
const { sso } = require('@bcgov/citz-imb-sso-express');

// Debug log to verify app startup
console.log('Starting application...');

// Debug log to verify environment variables
console.log('Environment variables:', {
APP_PORT: process.env.APP_PORT,
POSTGRES_HOST: process.env.POSTGRES_HOST,
POSTGRES_USER: process.env.POSTGRES_USER,
POSTGRES_PASSWORD: process.env.POSTGRES_PASSWORD,
POSTGRES_DB: process.env.POSTGRES_DB,
POSTGRES_PORT: process.env.POSTGRES_PORT,
});

const app = express();
const port = process.env.APP_PORT;

// Debug log to verify port configuration
console.log('Configured port:', port);

global.fetch = fetch;

console.log('Setting up SSO...');
sso(app, {
afterUserLogin: (user) => {
console.log(`User logged in: ${user.display_name}`);
Expand All @@ -20,28 +37,37 @@ sso(app, {
console.log(`User logged out: ${user.display_name}`);
},
});
console.log('SSO setup complete.');

//Health check
// Health check
app.get('/health', (req, res) => {
console.log('Health check endpoint hit.');
res.status(200).send('OK');
});

app.use(express.json());

// Debug log before setting up form routes
console.log('Setting up form routes...');
app.use('/api', protectedRoute(), formRoutes);
console.log('Form routes setup complete.');

// Debug middleware for incoming requests
app.use((req, res, next) => {
console.log(`Incoming request: ${req.method} ${req.url}`);
next();
});

app.use(express.static(path.join(__dirname, '../client/build')));

// Debug log for handling wildcard route
console.log('Setting up wildcard route for static files...');
app.get('*', (req, res) => {
console.log('Wildcard route hit.');
res.sendFile(path.join(__dirname, '../client/build', 'index.html'));
});

// Starting the server
app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);
});

2 changes: 1 addition & 1 deletion app/src/knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
},
pool: {
min: 2,
max: 10,
max: 50,
acquireTimeoutMillis: 60000,
afterCreate: (conn, done) => {
console.log(`[Knex] Connection created:`, conn);
Expand Down
1 change: 0 additions & 1 deletion app/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"pg": "^8.13.0"
},
"scripts": {
"migrate": "node ./app/src/migrate.js",
"start": "node ./app/src/index.js",
"dev": "nodemon ./app/src/index.js"
},
Expand Down
4 changes: 2 additions & 2 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ spec:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 10
initialDelaySeconds: 20
periodSeconds: 10
timeoutSeconds: 2
failureThreshold: 3
Expand All @@ -44,7 +44,7 @@ spec:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 5
initialDelaySeconds: 15
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 3
Expand Down

0 comments on commit f37cf58

Please sign in to comment.