Skip to content

Commit 9a2baea

Browse files
committed
docs: add mongoDB as local installed
1 parent 070a4b5 commit 9a2baea

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ No errors have been found or reported.
200200
- Generate script (bash, sh) that automates the renaming of files and content to replace `prototype` with a new desired name in the model and controller, as well as the API URL (router).
201201
- Generate a admin panel with a frontend (as react) that emulates the same functionalities as the [Django REST Framework](https://www.django-rest-framework.org/) and facilitates the management of models and API behaviour from a web interface.
202202
- Generate a web interface in the frontend that facilitates the creation of models and controllers.
203+
- Use morgan to extends the Express Rest API’s logging capabilities.
203204

204205
# Technologies Used
205206

@@ -299,6 +300,17 @@ npm start
299300

300301
##### Local in the computer
301302

303+
To install mongoDB y the local computer. With windows the instruction are [here](https://www.mongodb.com/try/download/community) and to mac I will use [Homebrew](https://brew.sh/):
304+
305+
```
306+
brew tap mongodb/brew
307+
brew install mongodb-community
308+
```
309+
310+
Finally, type `brew services start mongodb-community` into your terminal. This is what actually starts up the Mongo server. **You’ll need to have the Mongo server running any time you want to interact with your database, view your myFlix app, or use the Mongo shell**.
311+
312+
To stop running the Mongo server, enter the command `brew services stop mongodb-community` in your terminal.
313+
302314
##### MongoDB atlas as remote
303315

304316
Loggin and create account of [MongoDB Atlas](https://www.mongodb.com/atlas/database)
@@ -344,9 +356,9 @@ _Section is pending_
344356
### Create .env configuration file
345357

346358
```
347-
MONGODB_URI='mongodb+srv://username:password@url.mongodb.net/prototype?retryWrites=true&w=majority'
359+
MONGODB_URI='mongodb://localhost/prototype=test'
348360
349-
TEST_MONGODB_URI='mongodb+srv://username:password@url.mongodb.net/test-prototype?retryWrites=true&w=majority'
361+
TEST_MONGODB_URI='mongodb://localhost/test-prototype=test'
350362
351363
SECRET='your-secret-key-for-testing-purposes-only'
352364
@@ -369,7 +381,7 @@ npm run dev
369381
## Adding users
370382

371383
_You must install in vscode or another similar IDE the plugin: [REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) to be able to carry out these steps. [Here](https://fullstackopen.com/en/part3/node_js_and_express#the-visual-studio-code-rest-client) some instructions about how to use it_
372-
_Modify `requests\add_new_user.rest` to add the users you want. For instance (to add username `root` and `password` test):_
384+
_Modify `requests\user.rest` to add the users you want. For instance (to add username `root` and `password` test):_
373385

374386
<pre>
375387
POST http://localhost:3003/api/users
@@ -421,7 +433,7 @@ I would recommend (if you want to change to `blog` for example):
421433

422434
## Perform CRUD operations after modified the prototype
423435

424-
The file [requests/CRUD_prototypes.rest](requests/CRUD_prototypes.rest) can be used as a basis for performing CRUD operations on the modified model based on the controller operations (which must also be modified).
436+
The file [requests/prototype.rest](requests/prototype.rest) can be used as a basis for performing CRUD operations on the modified model based on the controller operations (which must also be modified).
425437

426438
_About the use of .rest files and REST Clients, the follow [section](https://github.com/patchamama/prototype-fast-dev-nodeJS-API#adding-users) can help._
427439

requests/user.rest

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
###
2+
# Get all users
3+
GET http://localhost:3003/api/users/
4+
15
# Create a new user
26
POST http://localhost:3003/api/users
37
Content-Type: application/json
@@ -21,9 +25,6 @@ Content-Type: application/json
2125
"email": "myemail@email.com"
2226
}
2327

24-
###
25-
GET http://localhost:3003/api/users/
26-
2728
###
2829
# Update a user
2930
PUT http://localhost:3003/api/users/64ff96536e561d986092af5f

tests/user.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const app = require('../app')
44
const api = supertest(app)
55
const bcrypt = require('bcrypt')
66
const User = require('../models/user')
7-
const { tokenExtractor } = require('../utils/middleware')
87

98
describe('when there is initially one user in db', () => {
109
let token // Token of authenticated user

0 commit comments

Comments
 (0)