feat: class connection will use from now the env variable
continuous-integration/drone/push Build is passing Details

pull/9/head
Rémi REGNAULT 1 year ago
parent 1dfc3040ad
commit ababfc7a33

@ -11,6 +11,7 @@
"dependencies": { "dependencies": {
"@types/express": "^4.17.21", "@types/express": "^4.17.21",
"@types/morgan": "^1.9.9", "@types/morgan": "^1.9.9",
"dotenv": "^16.3.1",
"express": "^4.18.2", "express": "^4.18.2",
"morgan": "^1.10.0", "morgan": "^1.10.0",
"nodemon": "^3.0.1", "nodemon": "^3.0.1",
@ -2237,6 +2238,17 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/dotenv": {
"version": "16.3.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/motdotla/dotenv?sponsor=1"
}
},
"node_modules/ee-first": { "node_modules/ee-first": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",

@ -8,12 +8,13 @@
"build": "tsup src/server.ts --format cjs --clean", "build": "tsup src/server.ts --format cjs --clean",
"dev": "nodemon --watch src -e js,ts,json --exec \"ts-node src/server.ts\"", "dev": "nodemon --watch src -e js,ts,json --exec \"ts-node src/server.ts\"",
"test": "jest --passWithNoTests" "test": "jest --passWithNoTests"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@types/express": "^4.17.21", "@types/express": "^4.17.21",
"@types/morgan": "^1.9.9", "@types/morgan": "^1.9.9",
"dotenv": "^16.3.1",
"express": "^4.18.2", "express": "^4.18.2",
"morgan": "^1.10.0", "morgan": "^1.10.0",
"nodemon": "^3.0.1", "nodemon": "^3.0.1",
@ -23,11 +24,9 @@
"typescript": "^5.2.2" "typescript": "^5.2.2"
}, },
"devDependencies": { "devDependencies": {
"@types/pg": "^8.10.9",
"@types/jest": "^29.5.8", "@types/jest": "^29.5.8",
"@types/pg": "^8.10.9",
"jest": "^29.7.0", "jest": "^29.7.0",
"ts-jest": "^29.1.1" "ts-jest": "^29.1.1"
} }
} }

@ -1,9 +1,6 @@
import { Request, Response, NextFunction } from "express";
import { Router } from "express"; import { Router } from "express";
import { Exceptions } from "../utils/exception"; import { Exceptions } from "../utils/exception";
import { IIngredient, Ingredient } from "../types/ingredients"; import { Ingredient } from "../types/ingredients";
import { pool } from "../database/connection";
import { Query, QueryResult } from "pg";
import { IngredientsGateway } from "../gateways/ingredients.gateway"; import { IngredientsGateway } from "../gateways/ingredients.gateway";

@ -1,5 +1,4 @@
import { Router } from "express"; import { Router } from "express";
import { Recipe } from "../types/recipes";
import { Exceptions } from "../utils/exception"; import { Exceptions } from "../utils/exception";
import { StepsGateway } from "../gateways/steps.gateway"; import { StepsGateway } from "../gateways/steps.gateway";

@ -1,15 +1,5 @@
import { Client } from "pg" import { Client } from "pg"
const Pool = require('pg').Pool
export const pool = new Pool({
user: 'rgregnault',
host: 'localhost',
database: 'leftovers',
password: 'motdepasse',
port: 5432,
})
export class Connection { export class Connection {
public client:Client public client:Client
@ -17,11 +7,11 @@ export class Connection {
constructor() { constructor() {
this.client = new Client({ this.client = new Client({
user: 'leftovers_appuser', user: process.env.DB_USERNAME,
host: 'postgresql-leftovers.alwaysdata.net', host: process.env.DB_DBHOST,
database: 'leftovers_recipedb', database: process.env.DB_DBNAME,
password: 'UsrPsswd', password: process.env.DB_USERPASSWORD,
port: 5432, port: Number(process.env.DB_PORT),
}) })
} }

@ -1,4 +1,3 @@
import { Recipe } from "../types/recipes"
import { Connection } from "../database/connection" import { Connection } from "../database/connection"
export class StepsGateway { export class StepsGateway {

@ -1,4 +1,7 @@
import express from "express"; import express from "express";
require('dotenv').config();
import { IngredientsController } from "./controllers/ingredients.controller"; import { IngredientsController } from "./controllers/ingredients.controller";
import { RecipesController } from "./controllers/recipes.controller"; import { RecipesController } from "./controllers/recipes.controller";
import { StepsController } from "./controllers/steps.controller"; import { StepsController } from "./controllers/steps.controller";

Loading…
Cancel
Save