Skip to content

Commit

Permalink
Update README.md (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
aboueleyes authored Nov 16, 2023
1 parent 5132337 commit 1ce9cf0
Showing 1 changed file with 66 additions and 7 deletions.
73 changes: 66 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ The system serves different type of users (Admin, Instructor , Individual Traine


## Code Examples 🐱‍💻
### Send Certificate Service

<details>
<summary>
Send Certificate Service
</summary>

```typescript
import { sendEmail } from "./sendMailService";
Expand All @@ -258,7 +262,14 @@ export const sendCertificateEmail = async (email: string, courseName: string, ce
sendEmail(email, context, "certificateUponCompletion", "Linear Depression | Congrats 🎉", attachments);
};
```
### Course Action Methods


</details>

<details>

<summary> Course Action Methods </summary>

```typescript
courseSchema.methods.close = async function (this: ICourseModel) {
if (this.status !== CourseStatus.PUBLISHED) {
Expand All @@ -284,7 +295,14 @@ courseSchema.methods.reOpen = async function (this: ICourseModel) {
await this.save();
};
```
### Setting Rate Limiter


</details>

<details>

<summary> Setting Rate Limiters </summary>

```typescript
const rateLimiter = (requestsPerMinute: number = 120) => {
return rateLimit({
Expand All @@ -299,7 +317,14 @@ const rateLimiter = (requestsPerMinute: number = 120) => {
});
};
```
### Caching Currency Rates

</details>
<details>

<summary>
Caching Currency Rates
</summary>

```typescript
// run every day at 00:00
const getCurrencyRatesTask = new CronJob("0 0 0 * * *", async () => {
Expand All @@ -323,7 +348,14 @@ const getCurrencyRatesTask = new CronJob("0 0 0 * * *", async () => {
fs.writeFileSync("src/media/currency-rates.json", JSON.stringify(currencyRates));
});
```
### Promotion Validator

</details>

<details>
<summary>
Promotion Validator
</summary>

```typescript
export const PromotionValidator = {
validate: async (promotion: IPromotionModel) => {
Expand All @@ -347,7 +379,15 @@ export const PromotionValidator = {
}
};
```
### Course NavBar

</details>

<details>

<summary>
Course NavBar
</summary>

```typescript
<HorizontalContainer>
<NavItem>
Expand Down Expand Up @@ -380,7 +420,16 @@ export const PromotionValidator = {
)}
</HorizontalContainer>
```
### Question Card

</details>


<details>

<summary>
Question Card
</summary>

```typescript
<ErrorCourseCard>
<div key={index}>
Expand Down Expand Up @@ -422,6 +471,8 @@ export const PromotionValidator = {
</ErrorCourseCard>
```

</details>

## Running Tests 🧪

The testing is done using `jest`. To run the tests, run the following command
Expand Down Expand Up @@ -520,6 +571,12 @@ the backend server and client will be running on the specified ports on your env

To run this project, you will need to add the following environment variables to your .env file

<details>
<summary>
envs
</summary>


`REACT_APP_API_URL`

`REACT_APP_STRIPE_PUBLISHABLE_KEY`
Expand Down Expand Up @@ -555,6 +612,8 @@ To run this project, you will need to add the following environment variables to
`STRIPE_WEBHOOK_SECRET`


</details>

## Optimizations

- Currency rates are cached using an cron job that runs at 12 AM.
Expand Down

0 comments on commit 1ce9cf0

Please sign in to comment.