fix some bugs
continuous-integration/drone/push Build is passing Details

pull/9/head
Rayhân HASSOU 1 year ago
parent 1c0d9f2f43
commit f9adc7d012

@ -11,8 +11,8 @@
"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",
"cors": "^2.8.5", "cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2", "express": "^4.18.2",
"helmet": "^7.1.0", "helmet": "^7.1.0",
"morgan": "^1.10.0", "morgan": "^1.10.0",

@ -71,15 +71,16 @@ export class IngredientsGateway {
} }
async getByLetter(letter: string): Promise<any> { async getByLetter(letter: string): Promise<any> {
this.connection.connect(); const client = await this.connection.getPoolClient()
const query = { const query = {
text: 'SELECT * FROM Ingredients i WHERE LOWER(SUBSTRING(i.name, 1, 1)) = $1', text: 'SELECT * FROM Ingredients i WHERE LOWER(SUBSTRING(i.name, 1, 1)) = $1',
values: [letter.toLowerCase()], values: [letter.toLowerCase()],
}; };
const res = await this.connection.client.query(query); const res = await client.query(query);
console.log(res)
client.release()
if (res.rowCount === 0) { if (res.rowCount === 0) {
return null; return null;
@ -96,15 +97,16 @@ export class IngredientsGateway {
} }
async filter(prompt: string): Promise<any> { async filter(prompt: string): Promise<any> {
this.connection.connect(); const client = await this.connection.getPoolClient()
const query = { const query = {
text: 'SELECT * FROM Ingredients WHERE LOWER(name) LIKE $1', text: 'SELECT * FROM Ingredients WHERE LOWER(name) LIKE $1',
values: [`%${prompt.toLowerCase()}%`], values: [`%${prompt.toLowerCase()}%`],
}; };
const res = await this.connection.client.query(query); const res = await client.query(query);
console.log(res)
client.release()
if (res.rowCount === 0) { if (res.rowCount === 0) {
return null; return null;

@ -1,10 +1,12 @@
import express from "express";
require('dotenv').config(); require('dotenv').config();
import express from "express";
import cors from "cors"; import cors from "cors";
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";
let helmet = require("helmet"); let helmet = require("helmet");
let app = express(); let app = express();
app.use(helmet.hidePoweredBy()); app.use(helmet.hidePoweredBy());

Loading…
Cancel
Save