Skip to content

Commit

Permalink
better README
Browse files Browse the repository at this point in the history
  • Loading branch information
YoavKo committed May 1, 2022
1 parent b1476e2 commit 491a8a1
Showing 1 changed file with 65 additions and 6 deletions.
71 changes: 65 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,71 @@
# Aliens DB App
===============
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:

## DB implemantions notes:
# | 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

* I considered handle the input validation by SQL constraints by holdings tables which decler
"licenses to use" of weapons and vehicles for specific types of aliens. I drop this idea and
choosed to implament this roles by JS, for reduce the number of DB requests.

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/


* 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.
like:
$ 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"}'



Home Exam Implemantions Notes:
==============================

DB modoal:
----------
* I considered handle the input validation by SQL constraints by holdings tables which
decler "licenses to use" of weapons and vehicles for specific types of aliens. I drop
this idea and choosed to implament this roles by JS, for reduce the number of DB
requests, and for the SQL-DB setings be easy to maintain.

* I chose a direct approach in designing one table of data, as follows:
mysql> DESCRIBE aliens;
Expand Down

0 comments on commit 491a8a1

Please sign in to comment.