Skip to content

Commit

Permalink
docs: add mongoDB as local installed
Browse files Browse the repository at this point in the history
  • Loading branch information
patchamama committed Sep 13, 2023
1 parent 070a4b5 commit 9a2baea
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ No errors have been found or reported.
- 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).
- 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.
- Generate a web interface in the frontend that facilitates the creation of models and controllers.
- Use morgan to extends the Express Rest API’s logging capabilities.

# Technologies Used

Expand Down Expand Up @@ -299,6 +300,17 @@ npm start

##### Local in the computer

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/):

```
brew tap mongodb/brew
brew install mongodb-community
```

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**.

To stop running the Mongo server, enter the command `brew services stop mongodb-community` in your terminal.

##### MongoDB atlas as remote

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

```
MONGODB_URI='mongodb+srv://username:password@url.mongodb.net/prototype?retryWrites=true&w=majority'
MONGODB_URI='mongodb://localhost/prototype=test'
TEST_MONGODB_URI='mongodb+srv://username:password@url.mongodb.net/test-prototype?retryWrites=true&w=majority'
TEST_MONGODB_URI='mongodb://localhost/test-prototype=test'
SECRET='your-secret-key-for-testing-purposes-only'
Expand All @@ -369,7 +381,7 @@ npm run dev
## Adding users

_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_
_Modify `requests\add_new_user.rest` to add the users you want. For instance (to add username `root` and `password` test):_
_Modify `requests\user.rest` to add the users you want. For instance (to add username `root` and `password` test):_

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

## Perform CRUD operations after modified the prototype

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

_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._

Expand Down
7 changes: 4 additions & 3 deletions requests/user.rest
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
###
# Get all users
GET http://localhost:3003/api/users/

# Create a new user
POST http://localhost:3003/api/users
Content-Type: application/json
Expand All @@ -21,9 +25,6 @@ Content-Type: application/json
"email": "myemail@email.com"
}

###
GET http://localhost:3003/api/users/

###
# Update a user
PUT http://localhost:3003/api/users/64ff96536e561d986092af5f
Expand Down
1 change: 0 additions & 1 deletion tests/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const app = require('../app')
const api = supertest(app)
const bcrypt = require('bcrypt')
const User = require('../models/user')
const { tokenExtractor } = require('../utils/middleware')

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

0 comments on commit 9a2baea

Please sign in to comment.