Skip to content

Commit

Permalink
modified the backend documentation file
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisTemoye committed Jun 12, 2024
1 parent 68feea2 commit fd682b3
Showing 1 changed file with 112 additions and 59 deletions.
171 changes: 112 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,10 @@
<p align="center">
# Inventors Website Backend

<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>

</p>

[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>

<p align="center">

<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>

<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>

<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>

<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>

<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>

<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>

<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>

<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>

<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>

<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>

<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>

</p>

<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
This repository contains the backend code for the Inventors website.

## Description

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
This is the inventors website backend project

## Setup the app

Expand All @@ -60,37 +23,63 @@ Once you have cloned the project on your system, you will have your copy of the
For the application to function properly when running it, you need to setup some necessary Environment Variables in your `.env` file

1. Create a file `.env` in your project root folder.

2. Copy the Environment Variables from your `.env.sample` to your newly created `.env file`

```
NODE_ENV=development
PORT=3888
APP_DATABASE_URL=mongodb://localhost:27017/inventor_app?retryWrites=true&w=majority
LOG_DATABASE_URL=mongodb://localhost:27017/inventor_log?retryWrites=true&w=majority
JWT_SECRET=
JWT_EXPIRES=60
RATE_LIMIT_REQUEST_SIZE=60
RATE_LIMIT_TTL=30
```

3. Create a Cloudinary account with this [link](https://cloudinary.com/users/register_free)

4. Navigate to your dashboard in your Cloudinary account and copy the following Environment Variables.

```
//Cloudinary Environment Variables
CLOUDINARY_NAME=[Enter your Cloudinary name here]
CLOUDINARY_KEY=[Enter your Cloudinary key here]
CLOUDINARY_SECRET= [Enter your Cloudinary secret here]
```

Once you have copied your unique Environment Variables, paste them into your `.env` file as shown in the code above.
Expand All @@ -99,40 +88,60 @@ Once you have copied your unique Environment Variables, paste them into your `.e

```bash



$ npm install



```

## Running the app

```bash



# development



$ nest start --watch



# production mode



$ npm run start:prod



```

Once the application is running, your terminal should display a message similar to:

```
Inventor application is running on: http://[::1]:3888
```

Here, `3888` is the port number on which the application is running. This port number depends on the value you specify in your `.env` file under the `PORT` variable:

```
PORT=[YOUR_PORT_NUMBER]
```

To access the Swagger documentation for the API endpoints, open your web browser and navigate to the following URL, replacing `3888` with your specified port number:

```
http://[::1]:[YOUR_PORT_NUMBER]/docs/api
```

This URL will take you to the Swagger interface, where you can explore and interact with the API endpoints.
Expand All @@ -156,23 +165,41 @@ The first step is to register a new user. This is required to create an account
**Request Body:**

````
```json
{
"email": "string",
"password": "string",
"firstName": "string",
"lastName": "string",
"joinMethod": "SIGN_UP",
"location": {
"type": "Point",
"coordinates": [
"longitude",
"latitude"
]
"type": "Point",
"coordinates": [
"longitude",
"latitude"
]
},
"deviceId": "string",
"deviceToken": "string"
}
````

### 2. Verify the User
Expand All @@ -185,6 +212,8 @@ To verify the user using the Swagger documentation, you'll need to provide the *

```
```

### 3. Log In
Expand All @@ -196,38 +225,56 @@ Once the user is verified, you can log in to obtain an authentication token.
**Request Body:**

```
{
"email": "string",
"password": "string"
"email": "string",
"password": "string"
}
```

**Response:** The response will contain an authentication token, which you will use for authenticated requests.

```
{
"access_token": "your_auth_token",
"_id": "your_userId",
"email": "your_email_address",
"firstName": "your_firstname",
"lastName": "your_lastname",
"role": [ "USER" ]
}
```

### 4. Add the Auth Token to Swagger

To interact with the secured endpoints in the Swagger documentation, you need to add the obtained authentication token.

1. Open the Swagger documentation for your API.
2. Click on the **Authorize** button (usually a padlock icon) at the top of the page.
3. In the popup that appears, enter your authentication token in the appropriate field. The format usually is:
1. Open the Swagger documentation for your API.

2. Click on the **Authorize** button (usually a padlock icon) at the top of the page.

3. In the popup that appears, enter your authentication token in the appropriate field. The format usually is:

```
Bearer your_auth_token
```

4. Click **Authorize** to apply the token.
4. Click **Authorize** to apply the token.

With the authentication token added, you can now interact with the secured endpoints in the Swagger documentation. The token will be included in the `Authorization` header of your requests.

Expand All @@ -237,35 +284,41 @@ Ensure you replace placeholder values (e.g., `your_firstname`,`your_lastname`, `

```bash



# unit tests



$ npm run test





# e2e tests



$ npm run test:e2e





# test coverage

$ npm run test:cov

```

## Support
$ npm run test:cov

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).

## Stay in touch

- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
```

- Website - [https://nestjs.com](https://nestjs.com/)
## Support

- Twitter - [@nestframework](https://twitter.com/nestframework)
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).

## License

Expand Down

0 comments on commit fd682b3

Please sign in to comment.