Skip to content

Commit 591bdf4

Browse files
author
Ben
committed
Update Readme with new routes and info
1 parent 4be70aa commit 591bdf4

File tree

1 file changed

+41
-37
lines changed

1 file changed

+41
-37
lines changed

README.md

+41-37
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
## This repo can be cloned/forked and used as a boilerplate for a node REST API
44

5-
I built this repo to learn how to make a rest api and server. It was created by following [this tutorial](https://www.codementor.io/olatundegaruba/nodejs-restful-apis-in-10-minutes-q0sgsfhbd), and has been expanded on to service the needs of a boilerplate project.
5+
I built this repo to learn how to make a rest api and server. It was created by following [this tutorial](https://www.codementor.io/olatundegaruba/nodejs-restful-apis-in-10-minutes-q0sgsfhbd), and has been expanded on to service the needs of a boilerplate project. I've also used inspiration from [this awesome dev!](https://github.com/christopherliedtke)
66

77
The different things you can do with this server:
88

9-
- Controllers - deals with database read/write operations
10-
- Models - define schemas of objects in collections the database
11-
- Routes - defines the API routing for controller functions
12-
- Middlewares - helper files and methods
9+
- Controllers - deals with database read/write operations and logic.
10+
- Models - define schemas of objects in collections the database.
11+
- Routes - defines the API routing for controller functions.
12+
- Middlewares - helper files, utils and methods. Basically anything that isn't done by a controller.
1313

1414
### Installing & config
1515

@@ -25,7 +25,7 @@ The different things you can do with this server:
2525

2626
2. Add a `JWT_SECRET` to the `.env` file
2727

28-
3. Start the server with nodemon: `npm start`
28+
3. Start the server with nodemon: `npm start`. Currently the default port for the server is `5000` and this can be set in the `.env`. This is to prevent clashes when running the server and clients in dev locally.
2929

3030
4. Restart running server by typing: `rs`
3131

@@ -41,70 +41,74 @@ The different things you can do with this server:
4141

4242
### Auth Routes
4343

44-
`/api/auth/create-new-user`
44+
#### `/api/v1/auth/login-user`
4545

4646
```javascript
4747
POST:
4848
{
49-
"firstName": "null", (firstName is optional)
50-
"lastName": "null", (lastName is optional)
51-
"email": "[email protected]",
52-
"password": "test" (min 6 chars)
49+
"email": "",
50+
"password": "" (at least 6 characters long and contain a lowercase letter, an uppercase letter, a numeric digit and a special character.)
5351
}
5452
```
5553

56-
`/api/auth/login-user`
54+
#### `/api/v1/auth/create-new-user`
5755

5856
```javascript
5957
POST:
6058
{
61-
"email": "[email protected]",
62-
"password": "test" (min 6 chars)
59+
"firstName": "", (firstName is optional)
60+
"lastName": "", (lastName is optional)
61+
"email": "",
62+
"password": "" (at least 6 characters long and contain a lowercase letter, an uppercase letter, a numeric digit and a special character.)
63+
"password2": ""
64+
"acceptedTerms": Boolean
6365
}
6466
```
6567

66-
`/api/auth/check-token-valid/:token`
68+
#### `/api/v1/auth/verification/verify-account/:uniqueId/:secretCode`
6769

68-
```javascript
69-
GET:
70-
token - this needs to be JWT token provided when logging in
71-
```
70+
This route is activated when a user clicks the link in an email sent to then when creating a new account.
7271

73-
### Todo Routes
72+
#### `/api/v1/auth/password-reset/get-code`
7473

75-
`/api/tasks/create-new-task/:token`
74+
Allows a user to get a password reset code emailed to them.
7675

7776
```javascript
78-
POST
77+
POST:
7978
{
80-
"task": "string",
81-
"userId": "string <-- needs to be the userId from mongodb"
79+
"email": "",
80+
"password": "",
81+
"password2": "",
82+
"code": "" (this will have been emailed to the user)
8283
}
8384
```
8485

85-
`/api/tasks/read-all-user-tasks/:userId/:token`
86+
#### `/api/v1/auth/password-reset/verify-code
87+
88+
Allows a user to get a password reset code emailed to them.
8689

8790
```javascript
88-
GET
89-
Gets all the tasks from a single user
91+
POST:
92+
{
93+
"email": ""
94+
}
9095
```
9196

92-
`/api/tasks/:userId/:token/:taskId`
97+
#### `/api/v1/auth/delete-account`
9398

94-
```javascript
95-
GET
96-
Gets a single task from a single user
97-
```
99+
Allows a user to delete their account.
98100

99101
```javascript
100-
Updates a single task text
101-
PUT
102+
POST:
102103
{
103-
"task": "string"
104+
"password": "",
105+
"uniqueId": ""
104106
}
105107
```
106108

109+
#### `/api/v1/auth/check-token-valid-external/:token`
110+
107111
```javascript
108-
DELETE
109-
Deletes a single task
112+
GET
113+
External route to check if a token is valid
110114
```

0 commit comments

Comments
 (0)