made updates to load envs and streamline pg pool to cut down on connections (#15)
Reviewed-on: #15 Co-authored-by: Joseph Nelson <joseph.nelson4456@gmail.com> Co-committed-by: Joseph Nelson <joseph.nelson4456@gmail.com>
This commit was merged in pull request #15.
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
import express from 'express'
|
||||
import jwt from 'jsonwebtoken'
|
||||
import bcrypt from 'bcryptjs'
|
||||
import { database, jwtEnv } from '../../config/index.js'
|
||||
import { Pool } from 'pg'
|
||||
import { pool, jwtEnv } from '../../config/index.js'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
// Database connection pool
|
||||
const pool = new Pool(database)
|
||||
|
||||
// Route to handle login and issue JWT token
|
||||
router.post('/login', async (req, res) => {
|
||||
const { username, password } = req.body
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import express from 'express'
|
||||
import { Pool } from 'pg'
|
||||
import { database } from '../../config/index.js'
|
||||
import { pool } from '../../config/index.js'
|
||||
import { check, validationResult } from 'express-validator'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
// Create a connection pool to the database
|
||||
const pool = new Pool(database)
|
||||
|
||||
// Get all collections
|
||||
router.get('/', async (req, res) => {
|
||||
try {
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import express from 'express'
|
||||
import { Pool } from 'pg'
|
||||
import { database } from '../../config/index.js'
|
||||
import { pool } from '../../config/index.js'
|
||||
import { check, validationResult } from 'express-validator'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
// Create a connection pool to the database
|
||||
const pool = new Pool(database)
|
||||
|
||||
// CREATE AN IMAGE
|
||||
router.post(
|
||||
'/',
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import express from 'express'
|
||||
import { Pool } from 'pg'
|
||||
import { database } from '../../config/index.js'
|
||||
import { pool } from '../../config/index.js'
|
||||
import { check, validationResult } from 'express-validator'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
// Create a connection pool to the database
|
||||
const pool = new Pool(database)
|
||||
|
||||
// Get all items
|
||||
router.get('/', async (req, res) => {
|
||||
const client = await pool.connect()
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import express from 'express'
|
||||
import { Pool } from 'pg'
|
||||
import { database } from '../../config/index.js'
|
||||
import { pool } from '../../config/index.js'
|
||||
import { check, validationResult } from 'express-validator'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
// Create a connection pool to the database
|
||||
const pool = new Pool(database)
|
||||
|
||||
// Create a new location
|
||||
router.post(
|
||||
'/',
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import express from 'express'
|
||||
import { database } from '../../config/index.js'
|
||||
import { Pool } from 'pg'
|
||||
import { pool } from '../../config/index.js'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
// Create a connection pool to the database
|
||||
const pool = new Pool(database)
|
||||
|
||||
// Create a new role
|
||||
router.post('/', async (req, res) => {
|
||||
const { name } = req.body
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import express from 'express'
|
||||
import { Pool } from 'pg'
|
||||
import { database } from '../../config/index.js'
|
||||
import { pool } from '../../config/index.js'
|
||||
import { check, validationResult } from 'express-validator'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
// Create a connection pool to the database
|
||||
const pool = new Pool(database)
|
||||
|
||||
// Get all sets
|
||||
router.get('/', async (req, res) => {
|
||||
try {
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import express from 'express'
|
||||
import { database } from '../../config/index.js'
|
||||
import { Pool } from 'pg'
|
||||
import { pool } from '../../config/index.js'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
// Create a connection pool to the database
|
||||
const pool = new Pool(database)
|
||||
|
||||
/**
|
||||
* Get all users.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user