Skip to content

Commit

Permalink
Merge pull request #365 from ageddesi/dev
Browse files Browse the repository at this point in the history
v0.20.0 candidate
  • Loading branch information
ageddesi authored Oct 16, 2023
2 parents 50c03d2 + 7d6028d commit a5327b0
Show file tree
Hide file tree
Showing 9 changed files with 675 additions and 14 deletions.
10 changes: 10 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,16 @@
"contributions": [
"code"
]
},
{
"login": "shodown96",
"name": "Elijah Soladoye",
"avatar_url": "https://avatars.githubusercontent.com/u/41167893?v=4",
"profile": "http://elijahsoladoye.vercel.app",
"contributions": [
"code",
"doc"
]
}
],
"contributorsPerLine": 7,
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-51-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-52-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

<p align="center" style="margin-bottom: 20px">
Expand Down Expand Up @@ -181,6 +181,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tr>
<td align="center" valign="top" width="14.28%"><a href="http://suppergerrie2.com"><img src="https://avatars.githubusercontent.com/u/15769860?v=4?s=100" width="100px;" alt="Suppergerrie2"/><br /><sub><b>Suppergerrie2</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=suppergerrie2" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/dipushrestha"><img src="https://avatars.githubusercontent.com/u/36785868?v=4?s=100" width="100px;" alt="Dipendra Shrestha"/><br /><sub><b>Dipendra Shrestha</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=dipushrestha" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://elijahsoladoye.vercel.app"><img src="https://avatars.githubusercontent.com/u/41167893?v=4?s=100" width="100px;" alt="Elijah Soladoye"/><br /><sub><b>Elijah Soladoye</b></sub></a><br /><a href="https://github.com/ageddesi/Mocked-API/commits?author=shodown96" title="Code">💻</a> <a href="https://github.com/ageddesi/Mocked-API/commits?author=shodown96" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ SENTRY_DSN=https://23423423.ingest.sentry.io/234234
ENABLE_SENTRY=false
ENABLE_RATE_LIMIT=false
ENABLE_MORGAN_LOGGING=false
ENABLE_SWAGGER=false
ENABLE_SWAGGER=true
8 changes: 7 additions & 1 deletion api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ app.get('/full-status', (req, res) => {

app.use(cors()); // enabling CORS for all requests;

if (process.env.ENABLE_SWAGGER === 'true') initSwagger(app); // setup Swagger;
if (process.env.ENABLE_SWAGGER === 'true'){
initSwagger(app); // setup Swagger;
} else {
app.get('/', (req, res) => {
res.status(200).send('Welcome to the Mocked API')
})
}

export default app;
13 changes: 2 additions & 11 deletions api/src/modules/ecommerce/api/ecommerce-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,6 @@ import { getEcommerceCart } from '../utils/get-ecommerce-cart';
* $ref: '#/definitions/MockEcommerceProduct'
*/

/**
* @openapi
* definitions:
* MockEcommerceCartList:
* type: array
* items:
* $ref: '#/definitions/MockEcommerceCart'
*/

module.exports = function (app: core.Express) {

Check warning on line 83 in api/src/modules/ecommerce/api/ecommerce-routes.ts

View check run for this annotation

Codeac.io / Codeac Code Quality

only-arrow-functions

non-arrow functions are forbidden
/**
* @openapi
Expand Down Expand Up @@ -118,12 +109,12 @@ module.exports = function (app: core.Express) {
* parameters:
* - in: path
* name: qty
* description: The number of carts you want
* description: The number of products you want in your cart
* responses:
* '200':
* description: OK
* schema:
* $ref: '#/definitions/MockEcommerceCartList'
* $ref: '#/definitions/MockEcommerceCart'
*/
app.get('/ecommerce/cart/:qty', (req: Request, res: Response) => {
const ecommerceCart = getEcommerceCart(req);
Expand Down
52 changes: 52 additions & 0 deletions api/src/modules/facts/api/facts-routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Request, Response } from 'express';
import * as core from 'express-serve-static-core';
import { getQtyFromRequest } from '../../../utils/route-utils';
import facts from '../data/facts';

module.exports = function (app: core.Express) {

Check warning on line 6 in api/src/modules/facts/api/facts-routes.ts

View check run for this annotation

Codeac.io / Codeac Code Quality

only-arrow-functions

non-arrow functions are forbidden
/**
* @openapi
* '/facts/random':
* get:
* tags:
* - Facts
* summary: Get a random fact from the database
* responses:
* '200':
* description: OK
* schema:
* type: object
* example: { fact: '', category: ''}
*/
app.get('/facts/random', (req: Request, res: Response) => {
const fact = facts[Math.floor(Math.random() * facts.length)];
res.json(fact);
});

/**
* @openapi
* '/facts/{qty}':
* get:
* tags:
* - Facts
* summary: Get a list of all facts from the database
* parameters:
* - in: path
* name: qty
* description: The amount of results you would like returned
* default: 10
* type: number
* responses:
* '200':
* description: OK
* schema:
* type: array
* items:
* type: object
* example: { fact: '', category: ''}
*/
app.get('/facts/:qty', (req: Request, res: Response) => {
const qty = getQtyFromRequest(req);
res.json(qty >= facts.length ? facts : facts.slice(0, qty));
});
};
Loading

0 comments on commit a5327b0

Please sign in to comment.