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": {
"@types/express": "^4.17.21",
"@types/morgan": "^1.9.9",
"dotenv": "^16.3.1",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"helmet": "^7.1.0",
"morgan": "^1.10.0",

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

@ -1,10 +1,12 @@
import express from "express";
require('dotenv').config();
import express from "express";
import cors from "cors";
import { IngredientsController } from "./controllers/ingredients.controller";
import { RecipesController } from "./controllers/recipes.controller";
import { StepsController } from "./controllers/steps.controller";
let helmet = require("helmet");
let app = express();
app.use(helmet.hidePoweredBy());

Loading…
Cancel
Save