Skip to content

Commit fd682b3

Browse files
committed
modified the backend documentation file
1 parent 68feea2 commit fd682b3

File tree

1 file changed

+112
-59
lines changed

1 file changed

+112
-59
lines changed

README.md

Lines changed: 112 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,10 @@
1-
<p align="center">
1+
# Inventors Website Backend
22

3-
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
4-
5-
</p>
6-
7-
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
8-
[circleci-url]: https://circleci.com/gh/nestjs/nest
9-
10-
<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>
11-
12-
<p align="center">
13-
14-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
15-
16-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
17-
18-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
19-
20-
<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>
21-
22-
<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>
23-
24-
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
25-
26-
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
27-
28-
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
29-
30-
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
31-
32-
<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>
33-
34-
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
35-
36-
</p>
37-
38-
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
39-
40-
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
3+
This repository contains the backend code for the Inventors website.
414

425
## Description
436

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

469
## Setup the app
4710

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

6225
1. Create a file `.env` in your project root folder.
26+
6327
2. Copy the Environment Variables from your `.env.sample` to your newly created `.env file`
6428

6529
```
30+
6631
NODE_ENV=development
6732
33+
34+
6835
PORT=3888
6936
37+
38+
7039
APP_DATABASE_URL=mongodb://localhost:27017/inventor_app?retryWrites=true&w=majority
7140
41+
42+
7243
LOG_DATABASE_URL=mongodb://localhost:27017/inventor_log?retryWrites=true&w=majority
7344
45+
46+
7447
JWT_SECRET=
7548
49+
50+
7651
JWT_EXPIRES=60
7752
53+
54+
7855
RATE_LIMIT_REQUEST_SIZE=60
7956
57+
58+
8059
RATE_LIMIT_TTL=30
60+
8161
```
8262

8363
3. Create a Cloudinary account with this [link](https://cloudinary.com/users/register_free)
64+
8465
4. Navigate to your dashboard in your Cloudinary account and copy the following Environment Variables.
8566

8667
```
68+
8769
//Cloudinary Environment Variables
8870
71+
72+
8973
CLOUDINARY_NAME=[Enter your Cloudinary name here]
9074
75+
76+
9177
CLOUDINARY_KEY=[Enter your Cloudinary key here]
9278
79+
80+
9381
CLOUDINARY_SECRET= [Enter your Cloudinary secret here]
82+
9483
```
9584

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

10089
```bash
10190

91+
92+
10293
$ npm install
10394

95+
96+
10497
```
10598

10699
## Running the app
107100

108101
```bash
109102

103+
104+
110105
# development
111106

107+
108+
112109
$ nest start --watch
113110

111+
112+
114113
# production mode
115114

115+
116+
116117
$ npm run start:prod
117118

119+
120+
118121
```
119122

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

122125
```
126+
123127
Inventor application is running on: http://[::1]:3888
128+
124129
```
125130

126131
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:
127132

128133
```
134+
129135
PORT=[YOUR_PORT_NUMBER]
136+
130137
```
131138

132139
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:
133140

134141
```
142+
135143
http://[::1]:[YOUR_PORT_NUMBER]/docs/api
144+
136145
```
137146

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

158167
````
168+
159169
```json
170+
160171
{
172+
161173
"email": "string",
174+
162175
"password": "string",
176+
163177
"firstName": "string",
178+
164179
"lastName": "string",
180+
165181
"joinMethod": "SIGN_UP",
182+
166183
"location": {
167-
"type": "Point",
168-
"coordinates": [
169-
"longitude",
170-
"latitude"
171-
]
184+
185+
"type": "Point",
186+
187+
"coordinates": [
188+
189+
"longitude",
190+
191+
"latitude"
192+
193+
]
194+
172195
},
196+
173197
"deviceId": "string",
198+
174199
"deviceToken": "string"
200+
175201
}
202+
176203
````
177204

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

186213
```
187214
215+
216+
188217
```
189218

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

198227
```
228+
199229
{
200-
"email": "string",
201-
"password": "string"
230+
231+
"email": "string",
232+
233+
"password": "string"
234+
202235
}
236+
203237
```
204238

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

207241
```
242+
208243
{
244+
209245
"access_token": "your_auth_token",
246+
210247
"_id": "your_userId",
248+
211249
"email": "your_email_address",
250+
212251
"firstName": "your_firstname",
252+
213253
"lastName": "your_lastname",
254+
214255
"role": [ "USER" ]
256+
215257
}
258+
216259
```
217260

218261
### 4. Add the Auth Token to Swagger
219262

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

222-
1. Open the Swagger documentation for your API.
223-
2. Click on the **Authorize** button (usually a padlock icon) at the top of the page.
224-
3. In the popup that appears, enter your authentication token in the appropriate field. The format usually is:
265+
1. Open the Swagger documentation for your API.
266+
267+
2. Click on the **Authorize** button (usually a padlock icon) at the top of the page.
268+
269+
3. In the popup that appears, enter your authentication token in the appropriate field. The format usually is:
225270

226271
```
272+
227273
Bearer your_auth_token
274+
228275
```
229276

230-
4. Click **Authorize** to apply the token.
277+
4. Click **Authorize** to apply the token.
231278

232279
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.
233280

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

238285
```bash
239286

287+
288+
240289
# unit tests
241290

291+
292+
242293
$ npm run test
243294

244295

245296

297+
298+
246299
# e2e tests
247300

301+
302+
248303
$ npm run test:e2e
249304

250305

251306

307+
308+
252309
# test coverage
253310

254-
$ npm run test:cov
255311

256-
```
257312

258-
## Support
313+
$ npm run test:cov
259314

260-
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).
261315

262-
## Stay in touch
263316

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

266-
- Website - [https://nestjs.com](https://nestjs.com/)
319+
## Support
267320

268-
- Twitter - [@nestframework](https://twitter.com/nestframework)
321+
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).
269322

270323
## License
271324

0 commit comments

Comments
 (0)