Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
YoavKo authored May 1, 2022
1 parent 1dc2260 commit a3b1e73
Showing 1 changed file with 41 additions and 37 deletions.
78 changes: 41 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,64 @@
Aliens DB App
=============
at - 2022-05-01.

by - Yoav Kostiner.

Running the app:
----------------
to set the app for work you need to run the next instarcions:

| # | Description | cmd |
|---|------------------------------|-----------------------------------|
| 1 | build and run DB container | $ docker-compose up -d --build |
| 2 | install node packages | $ npm i |
| 3 | insert initial data into DB | $ node db_data_init.js |
| 4 | finaly run the app | $ node app.js |
| # | Description | cmd |
|---|------------------------------|-----------------------------------------|
| 1 | build and run DB container | ``` $ docker-compose up -d --build ``` |
| 2 | install node packages | ``` $ npm i ``` |
| 3 | insert initial data into DB | ``` $ node db_data_init.js ``` |
| 4 | finaly run the app | ``` $ node app.js ``` |


API Docomantation:
------------------
I haved asket to implament the folloing commands;

* getAlien - returns a specific alien from the dataset
(fields: id, name, weapon, commander id, commander name, and
supervised alien ids list).

- for this cmd you shuld send a GET request to localhost:1212/<alien_id>
like:
$ curl -XGET localhost:1212/3
* getAll - returns all aliens from the dataset
(fields: id, name, weapon, commander id, and commander name).

- for this cmd you shuld send a GET request to localhost:1212/
like:
$ curl -XGET localhost:1212/
* getAlien
- returns a specific alien from the dataset
(fields: id, name, weapon, commander id, commander name, and
supervised alien ids list).

- for this cmd you shuld send a GET request to localhost:1212/<alien_id>

* newAlien - adds a new captured alien to the dataset.
```
$ curl -XGET localhost:1212/3
```
* getAll
- returns all aliens from the dataset
(fields: id, name, weapon, commander id, and commander name).
- for this cmd you shuld send a GET request to localhost:1212/
- for this cmd you shuld send a POST request to localhost:1212/ with it's record json
as the request body, make sure his commander is all redy in DB, and the alien has
lisence for the vehicle and weapon its holds, id will determined automatically.
like:
$ curl -XPOST localhost:1212/ -H "Content-Type:application/json" -d'{"name":"Avi",
"weapon":"Pepper spray", "commander_id":4, "type":"alien-warrior"}'
```
$ curl -XGET localhost:1212/
```
* updateAlien - updates a specific alien information (only the name, weapon, and
vehicle fields are updatable).

- for this cmd you shuld send a PUT request to localhost:1212/<alien_id> with the
data to update represents as json at the request body, make sure the alien has
lisence for the vehicle and weapon its holds.
* newAlien
- adds a new captured alien to the dataset.
- for this cmd you shuld send a POST request to localhost:1212/ with it's record json
as the request body, make sure his commander is all redy in DB, and the alien has
lisence for the vehicle and weapon its holds, id will determined automatically.
```
$ curl -XPOST localhost:1212/ -H "Content-Type:application/json" -d'{"name":"Avi", "weapon":"Pepper spray",
"commander_id":4, "type":"alien-warrior"}'
```
* updateAlien
- updates a specific alien information (only the name, weapon, and vehicle fields are updatable).
- for this cmd you shuld send a PUT request to localhost:1212/<alien_id> with the data to update
represents as json at the request body, make sure the alien has lisence for the vehicle and weapon its holds.
like:
$ curl -XPUT localhost:1212/3 -H "Content-Type:application/json" -d'{"name":"Yosi",
"weapon":"Water gun"}'

```
$ curl -XPUT localhost:1212/3 -H "Content-Type:application/json" -d'{"name":"Yosi", "weapon":"Water gun"}'
```
Home Exam Implemantions Notes:
Expand Down

0 comments on commit a3b1e73

Please sign in to comment.