From e352a26c6604f58e1ff39c81583651c177de76db Mon Sep 17 00:00:00 2001 From: Joseph Nelson Date: Sun, 17 May 2026 23:25:42 -0700 Subject: [PATCH] fixed file imports and added file with extension for imports (#9) Reviewed-on: https://gitea.nelson-household.com/Hard-at-Work/tcg-collectors-server/pulls/9 Co-authored-by: Joseph Nelson Co-committed-by: Joseph Nelson --- package.json | 1 - src/app.js | 18 +++++++++--------- src/config/index.js | 21 ++++++++++----------- src/routes/auth/index.js | 5 ++--- src/routes/collections/index.js | 5 ++--- src/routes/images/index.js | 5 ++--- src/routes/items/index.js | 5 ++--- src/routes/locations/index.js | 5 ++--- src/routes/roles/index.js | 5 ++--- src/routes/sets/index.js | 5 ++--- src/routes/users/index.js | 5 ++--- 11 files changed, 35 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index 9b281d2..0bb4fcb 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "migrate": "node-pg-migrate -m ./src/migrations", "test": "jest --forceExit" }, - "type": "module", "keywords": [ "express", "node.js", diff --git a/src/app.js b/src/app.js index db7150e..72cd1fd 100644 --- a/src/app.js +++ b/src/app.js @@ -1,15 +1,15 @@ import express from 'express' import path from 'path' import cors from 'cors' -import healthCheckRoutes from './routes/healthcheck' -import authRoutes from './routes/auth' -import userRoutes from './routes/users' -import roleRoutes from './routes/roles' -import locationRoutes from './routes/locations' -import imageRoutes from './routes/images' -import collectionRoutes from './routes/collections' -import setRoutes from './routes/sets' -import itemRoutes from './routes/items' +import healthCheckRoutes from './routes/healthcheck/index.js' +import authRoutes from './routes/auth/index.js' +import userRoutes from './routes/users/index.js' +import roleRoutes from './routes/roles/index.js' +import locationRoutes from './routes/locations/index.js' +import imageRoutes from './routes/images/index.js' +import collectionRoutes from './routes/collections/index.js' +import setRoutes from './routes/sets/index.js' +import itemRoutes from './routes/items/index.js' const app = express() const port = process.env.PORT || 3000 diff --git a/src/config/index.js b/src/config/index.js index e7adcca..093db6b 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -1,13 +1,12 @@ // config/index.js -export default { - database: { - host: process.env.DB_HOST || 'localhost', - user: process.env.DB_USER || 'your_db_user', - password: process.env.DB_PASSWORD || 'your_db_password', - database: process.env.DB_NAME || 'your_db_name', - port: process.env.DB_PORT || 5432, - }, - jwtEnv: { - secret: process.env.JWT_SECRET || '', - }, +export const database = { + host: process.env.DB_HOST || 'localhost', + user: process.env.DB_USER || 'your_db_user', + password: process.env.DB_PASSWORD || 'your_db_password', + database: process.env.DB_NAME || 'your_db_name', + port: process.env.DB_PORT || 5432, +} + +export const jwtEnv = { + secret: process.env.JWT_SECRET || '', } diff --git a/src/routes/auth/index.js b/src/routes/auth/index.js index f6e0d4a..43ce5fa 100644 --- a/src/routes/auth/index.js +++ b/src/routes/auth/index.js @@ -1,9 +1,8 @@ import express from 'express' import jwt from 'jsonwebtoken' import bcrypt from 'bcryptjs' -import { database, jwtEnv } from '../../config' - -const { Pool } = require('pg') +import { database, jwtEnv } from '../../config/index.js' +import { Pool } from 'pg' const router = express.Router() diff --git a/src/routes/collections/index.js b/src/routes/collections/index.js index 85267a0..2a61e8c 100644 --- a/src/routes/collections/index.js +++ b/src/routes/collections/index.js @@ -1,8 +1,7 @@ import express from 'express' import { Pool } from 'pg' -import { database } from '../../config' - -const { check, validationResult } = require('express-validator') +import { database } from '../../config/index.js' +import { check, validationResult } from 'express-validator' const router = express.Router() diff --git a/src/routes/images/index.js b/src/routes/images/index.js index 4439ba7..bc1d168 100644 --- a/src/routes/images/index.js +++ b/src/routes/images/index.js @@ -1,8 +1,7 @@ import express from 'express' import { Pool } from 'pg' -import { database } from '../../config' - -const { check, validationResult } = require('express-validator') +import { database } from '../../config/index.js' +import { check, validationResult } from 'express-validator' const router = express.Router() diff --git a/src/routes/items/index.js b/src/routes/items/index.js index d535df4..9cc4ec4 100644 --- a/src/routes/items/index.js +++ b/src/routes/items/index.js @@ -1,8 +1,7 @@ import express from 'express' import { Pool } from 'pg' -import { database } from '../../config' - -const { check, validationResult } = require('express-validator') +import { database } from '../../config/index.js' +import { check, validationResult } from 'express-validator' const router = express.Router() diff --git a/src/routes/locations/index.js b/src/routes/locations/index.js index 2fd32ac..f0c199a 100644 --- a/src/routes/locations/index.js +++ b/src/routes/locations/index.js @@ -1,8 +1,7 @@ import express from 'express' import { Pool } from 'pg' -import { database } from '../../config' - -const { check, validationResult } = require('express-validator') +import { database } from '../../config/index.js' +import { check, validationResult } from 'express-validator' const router = express.Router() diff --git a/src/routes/roles/index.js b/src/routes/roles/index.js index 6530e17..134011f 100644 --- a/src/routes/roles/index.js +++ b/src/routes/roles/index.js @@ -1,7 +1,6 @@ import express from 'express' -import { database } from '../../config' - -const { Pool } = require('pg') +import { database } from '../../config/index.js' +import { Pool } from 'pg' const router = express.Router() diff --git a/src/routes/sets/index.js b/src/routes/sets/index.js index 26929fd..246b254 100644 --- a/src/routes/sets/index.js +++ b/src/routes/sets/index.js @@ -1,8 +1,7 @@ import express from 'express' import { Pool } from 'pg' -import { database } from '../../config' - -const { check, validationResult } = require('express-validator') +import { database } from '../../config/index.js' +import { check, validationResult } from 'express-validator' const router = express.Router() diff --git a/src/routes/users/index.js b/src/routes/users/index.js index 09cc91d..0d2f5f5 100644 --- a/src/routes/users/index.js +++ b/src/routes/users/index.js @@ -1,7 +1,6 @@ import express from 'express' -import { database } from '../../config' - -const { Pool } = require('pg') +import { database } from '../../config/index.js' +import { Pool } from 'pg' const router = express.Router()