Skip to content

Commit

Permalink
Merge pull request #117 from Noorin99/MOHAMMAD-ALMOHAMMAD/issue116
Browse files Browse the repository at this point in the history
Mohammad almohammad/issue116
  • Loading branch information
MOHAMMAD-ALMOHAMMAD authored Aug 10, 2023
2 parents 34b1b12 + bb3032e commit 2faceec
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center">
<h1 align="center">Home Taste</h1>

<a href="https://pebble-work.herokuapp.com/api-docs/">
<a href="https://home-taste-api.onrender.com/api-docs">
<img src="./src/public/assets/logo.png" alt="Logo" width="150" >
</a>

Expand Down Expand Up @@ -281,11 +281,11 @@ This is known as a UML diagram, and it shows the collections used in the databas

## Documentation

Explore our interactive documentation API [here](https://pebble-work.up.railway.app/api-docs/).
Explore our interactive documentation API [here](https://home-taste-api.onrender.com/api-docs/).

<br>

![Swagger Documentation](/assets/documentation.png)
![Swagger Documentation](./src/public/assets/documentation.png)

## Contributors

Expand Down
5 changes: 2 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import swaggerUi from 'swagger-ui-express';
import * as dotenv from 'dotenv';
import path from 'path';
import errorHandler from './middlewares/error-handling';

dotenv.config();

import routes from './routes';
import { connectToMongo } from './db/connection';
import SwaggerOptions from './utils/variables';
import './config/passport';

dotenv.config();

const app = express();
app.use(cookieParser(process.env.SECRET_KEY));
app.use(express.urlencoded({ extended: false }));
Expand Down
8 changes: 6 additions & 2 deletions src/controllers/food.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ const getFoodFilter = async (req: Request, res: Response) => {
try {
const { categories } = req.query;
const { allergies } = req.query;
const query: { categories?: unknown; allergies?: unknown } = {};
const query: {
categories?: { $in: Array<string> };
allergies?: { $nin: Array<string> };
} = {};
if (categories) {
query.categories = { $in: (categories as string).split(',') };
}
if (allergies) {
query.allergies = { $nin: (allergies as string).split(',') };
}

const foods = await Food.find(query);
res.json(foods);
res.status(200).json(foods);
} catch (error) {
res.status(500).json({ message: error });
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/home.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<span class="tooltip">GitHub</span>
</div>
</a>
<a href="link-to-documentation" target="_blank">
<a href="api-docs" target="_blank">
<div class="icon-container">
<img
src="https://img.icons8.com/material-outlined/48/ffffff/document.png"
Expand Down

0 comments on commit 2faceec

Please sign in to comment.