made updates to load envs and streamline pg pool to cut down on connections
Test Workflow / test-and-lint (pull_request) Failing after 45s

This commit is contained in:
2026-05-30 23:44:00 -07:00
parent 42563e6f7c
commit c16eab58a2
12 changed files with 19 additions and 43 deletions
+2 -2
View File
@@ -18,7 +18,7 @@ ENV JWT_SECRET=${JWT_SECRET}
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN npm install --force --omit=dev && \ RUN npm install --force && \
echo "DATABASE_URL=${DATABASE_URL}" >> .env && \ echo "DATABASE_URL=${DATABASE_URL}" >> .env && \
echo "DB_HOST=${DB_HOST}" >> .env && \ echo "DB_HOST=${DB_HOST}" >> .env && \
echo "DB_USERNAME=${DB_USERNAME}" >> .env && \ echo "DB_USERNAME=${DB_USERNAME}" >> .env && \
@@ -27,4 +27,4 @@ RUN npm install --force --omit=dev && \
echo "DB_DATABASE=${DB_DATABASE}" >> .env && \ echo "DB_DATABASE=${DB_DATABASE}" >> .env && \
echo "JWT_SECRET=${JWT_SECRET}" >> .env echo "JWT_SECRET=${JWT_SECRET}" >> .env
CMD ["node", "--env-file=.env", "src/app.js"] CMD ["npm", "run", "docker:start"]
+1
View File
@@ -6,6 +6,7 @@
"scripts": { "scripts": {
"dev": "nodemon src/app.js", "dev": "nodemon src/app.js",
"start": "node src/app.js", "start": "node src/app.js",
"docker:start": "node --env-file=.env src/app.js",
"lint": "eslint .", "lint": "eslint .",
"lint:fix": "eslint . --fix", "lint:fix": "eslint . --fix",
"migrate": "node-pg-migrate -m ./src/migrations", "migrate": "node-pg-migrate -m ./src/migrations",
+3
View File
@@ -1,3 +1,6 @@
import { loadEnvFile } from 'node:process'
loadEnvFile() // load envs asap
import express from 'express' import express from 'express'
import path from 'path' import path from 'path'
import cors from 'cors' import cors from 'cors'
+5 -1
View File
@@ -1,5 +1,7 @@
// config/index.js // config/index.js
export const database = { import { Pool } from 'pg'
const database = {
host: process.env.DB_HOST, host: process.env.DB_HOST,
user: process.env.DB_USER, user: process.env.DB_USER,
password: process.env.DB_PASSWORD, password: process.env.DB_PASSWORD,
@@ -7,6 +9,8 @@ export const database = {
port: parseInt(process.env.DB_PORT, 10), port: parseInt(process.env.DB_PORT, 10),
} }
export const pool = new Pool(database)
export const jwtEnv = { export const jwtEnv = {
secret: process.env.JWT_SECRET, secret: process.env.JWT_SECRET,
} }
+1 -5
View File
@@ -1,14 +1,10 @@
import express from 'express' import express from 'express'
import jwt from 'jsonwebtoken' import jwt from 'jsonwebtoken'
import bcrypt from 'bcryptjs' import bcrypt from 'bcryptjs'
import { database, jwtEnv } from '../../config/index.js' import { pool, jwtEnv } from '../../config/index.js'
import { Pool } from 'pg'
const router = express.Router() const router = express.Router()
// Database connection pool
const pool = new Pool(database)
// Route to handle login and issue JWT token // Route to handle login and issue JWT token
router.post('/login', async (req, res) => { router.post('/login', async (req, res) => {
const { username, password } = req.body const { username, password } = req.body
+1 -5
View File
@@ -1,13 +1,9 @@
import express from 'express' import express from 'express'
import { Pool } from 'pg' import { pool } from '../../config/index.js'
import { database } from '../../config/index.js'
import { check, validationResult } from 'express-validator' import { check, validationResult } from 'express-validator'
const router = express.Router() const router = express.Router()
// Create a connection pool to the database
const pool = new Pool(database)
// Get all collections // Get all collections
router.get('/', async (req, res) => { router.get('/', async (req, res) => {
try { try {
+1 -5
View File
@@ -1,13 +1,9 @@
import express from 'express' import express from 'express'
import { Pool } from 'pg' import { pool } from '../../config/index.js'
import { database } from '../../config/index.js'
import { check, validationResult } from 'express-validator' import { check, validationResult } from 'express-validator'
const router = express.Router() const router = express.Router()
// Create a connection pool to the database
const pool = new Pool(database)
// CREATE AN IMAGE // CREATE AN IMAGE
router.post( router.post(
'/', '/',
+1 -5
View File
@@ -1,13 +1,9 @@
import express from 'express' import express from 'express'
import { Pool } from 'pg' import { pool } from '../../config/index.js'
import { database } from '../../config/index.js'
import { check, validationResult } from 'express-validator' import { check, validationResult } from 'express-validator'
const router = express.Router() const router = express.Router()
// Create a connection pool to the database
const pool = new Pool(database)
// Get all items // Get all items
router.get('/', async (req, res) => { router.get('/', async (req, res) => {
const client = await pool.connect() const client = await pool.connect()
+1 -5
View File
@@ -1,13 +1,9 @@
import express from 'express' import express from 'express'
import { Pool } from 'pg' import { pool } from '../../config/index.js'
import { database } from '../../config/index.js'
import { check, validationResult } from 'express-validator' import { check, validationResult } from 'express-validator'
const router = express.Router() const router = express.Router()
// Create a connection pool to the database
const pool = new Pool(database)
// Create a new location // Create a new location
router.post( router.post(
'/', '/',
+1 -5
View File
@@ -1,12 +1,8 @@
import express from 'express' import express from 'express'
import { database } from '../../config/index.js' import { pool } from '../../config/index.js'
import { Pool } from 'pg'
const router = express.Router() const router = express.Router()
// Create a connection pool to the database
const pool = new Pool(database)
// Create a new role // Create a new role
router.post('/', async (req, res) => { router.post('/', async (req, res) => {
const { name } = req.body const { name } = req.body
+1 -5
View File
@@ -1,13 +1,9 @@
import express from 'express' import express from 'express'
import { Pool } from 'pg' import { pool } from '../../config/index.js'
import { database } from '../../config/index.js'
import { check, validationResult } from 'express-validator' import { check, validationResult } from 'express-validator'
const router = express.Router() const router = express.Router()
// Create a connection pool to the database
const pool = new Pool(database)
// Get all sets // Get all sets
router.get('/', async (req, res) => { router.get('/', async (req, res) => {
try { try {
+1 -5
View File
@@ -1,12 +1,8 @@
import express from 'express' import express from 'express'
import { database } from '../../config/index.js' import { pool } from '../../config/index.js'
import { Pool } from 'pg'
const router = express.Router() const router = express.Router()
// Create a connection pool to the database
const pool = new Pool(database)
/** /**
* Get all users. * Get all users.
*/ */