Skip to content

Commit

Permalink
feat(api) update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
helderbetiol committed Jun 19, 2024
1 parent bf9cffc commit f6d6c3a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
44 changes: 22 additions & 22 deletions API/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Notes for The API
Designed with JWT, MongoDB and CI tested using Jenkins and docker with a
script to start up MongoDB
# OGrEE-API


Introduction
------------
This is an API interfacing with a MongoDB cluster for data centre management.


Expand Down Expand Up @@ -49,15 +44,8 @@ For Linux, consult your respective Distribution docs

Running
-------------
You can modify the port of the API in the .env file. This is the port that the API will use to listen for requests.
- Navigate in your terminal to the ```init_db``` directory
- Execute the bash script ```ogreeBoot.sh```
- Enter your password when the prompt asks you
- Be sure to enter your user password and the desired the DB access password
- Update your .env file ```db_user=myCompanyName``` and ```db_pass=dbAccessPassword```
- Execute the binary ```main```

This .env file is not provided, so you must create it yourself. Here is an example of the ```.env``` file:
This .env file is not provided, so you must create it yourself. Here is an example of the ```.env``` file to be placed in this same directory (`API/`):
```
PORT = 3001
db_host = 0.0.0.0
Expand All @@ -72,16 +60,28 @@ email_password = ""
reset_url = "http://localhost:8082/#/reset?token="
```

MongoDB
--------------------------
A document (JSON) Based Database. The current DB can be started using the **ogreemdb.sh** script found in the root dir. The most useful interface for the DB is to access the shell. If you have started the DB already using the script you can directly execute this command to access the DB Shell
```
mongo --shell
### With Docker Compose

There is a development version of the docker deploy with the following features:

* The MongoDB database is accessible on the `DB_PORT` (27017 by default) port. This will allow you to connect to the database using mongosh or mongodb-compass using the following url: `mongodb://ogreemytenantAdmin:pass123@localhost:27017/ogreemytenant?authSource=ogreemytenant&directConnection=true`.
* HotReload for the api: each time a change is made to the code, the api is recompiled and relaunched.

This version can be launched by running the following command in the `OGrEE-Core/deploy/` folder:

```bash
OGrEE-Core/deploy/> make dev_api
```

Running a MongoDB container
--------------------------
docker run --name mdb -v /home/ziad/mongoDir:/docker-entrypoint-initdb.d/ -p 27017:27017 -d mongo:latest
### With local Mongo

Considering you have a local Mongo installed, you can create a database locally to then connect your local API:
- Navigate in your terminal to the ```deploy/db``` directory
- Execute the bash script ```ogreeBoot.sh```
- Enter your password when the prompt asks you
- Be sure to enter your user password and the desired the DB access password
- Update your .env file ```db_user=myCompanyName``` and ```db_pass=dbAccessPassword```
- Execute the binary ```main```

Swagger Docs
--------------------------
Expand Down
Binary file removed BACK/app/ogree_app_backend
Binary file not shown.
2 changes: 1 addition & 1 deletion deploy/db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To build the docker image we need to run the `docker build` command at the `depl

```
# In the deploy directory, build the Docker image
docker build -f db/Dockerfile -t <tag_name> .
docker build -f db/Dockerfile -t ogree-mongo-rs .
```

**WARNING:** do not build the image using a machine with ARM architecture (for example all Macs with chip M*) as it will not work in our cluster.

0 comments on commit f6d6c3a

Please sign in to comment.