Skip to content
This repository was archived by the owner on Jun 11, 2022. It is now read-only.

Commit 3d2cb6b

Browse files
committed
Update README.md
1 parent ebc685b commit 3d2cb6b

File tree

1 file changed

+51
-39
lines changed

1 file changed

+51
-39
lines changed

README.md

+51-39
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#Java Web API
1+
# Java Web API
2+
23
A simple **standalone web application** providing API.
34

45
The API gives access to database resources and returns data in **JSON**.
@@ -9,7 +10,8 @@ Implemented with **DAO** pattern.
910

1011
Tested on **H2Database** v1.4.196.
1112

12-
##Configuration
13+
## Configuration
14+
1315
* Build using Maven `mvn install`
1416
* Create a new database
1517
* you can find **ready-to-go** database and .properties files in folder `/example_db`.
@@ -20,33 +22,57 @@ Tested on **H2Database** v1.4.196.
2022

2123
`example.properties`
2224
```
23-
<pre>
24-
url=<i>url of your database</i>
25-
driver=<i>jdbc driver of your database</i>
26-
username=<i>login for your database</i>
27-
password=<i>password for your database</i>
28-
</pre>
25+
url=*url of your database*
26+
driver=*jdbc driver of your database*
27+
username=*login for your database*
28+
password=*password for your database*
2929
```
3030
* Run application with the following parameters:
3131
* `-port [1024..49151]` - port number that will be used by server
3232
* `-dbProps path` - **relative** path to _.properties_ file
3333
* Now you are able to connect at localhost:_port_ and start sending requests!
3434
35-
##Authentication
35+
## Authentication
36+
3637
Every user of API has to pass his username and access token along with every request:
3738
3839
`/route?user=username&token=user_token&key1=val1&key2=val2...`
3940
4041
Of course, all parameters can occur in any order.
4142
42-
##Public routes
43+
## User roles
44+
45+
Every user is created with
46+
* role - _user_ (standard user) or _admin_ (administrator),
47+
* name,
48+
* access token,
49+
* usage limit.
50+
51+
After _limit_ requests, every user has to get his limit renewed by an admin.
52+
53+
### Standard user
54+
55+
Can access all **public** routes of the API in terms of his usage limits.
56+
57+
### Administrator
58+
59+
Can access **all routes** of the API in terms of his usage limits and has ability to:
60+
* access all users' data,
61+
* add new users,
62+
* delete current users,
63+
* renew current users' usage limits.
64+
65+
## Public routes
66+
4367
API consists of 3 public routes:
4468
* **/actors** - provides access to actors data
4569
* **/films** - provides access to films data
4670
* **/languages** - provides access to languages data
4771
48-
###GET Parameters
72+
### GET Parameters
73+
4974
#### All routes
75+
5076
All of the routes mentioned above provide:
5177
* obtaining all records under given route
5278
@@ -68,9 +94,10 @@ All of the routes mentioned above provide:
6894
6995
/languages?order=asc...
7096
71-
####Route-specific parameters
97+
#### Route-specific parameters
98+
99+
##### /actor
72100
73-
#####/actor
74101
* firstName
75102
76103
/actors?firstName=Woody...
@@ -80,7 +107,8 @@ All of the routes mentioned above provide:
80107
/actors?lastName=Williams...
81108
82109
83-
#####/film
110+
##### /film
111+
84112
You can mix title and language with both minLength and maxLength.
85113
86114
* title
@@ -97,42 +125,26 @@ You can mix title and language with both minLength and maxLength.
97125
98126
* maxLength (with duration equal or less than)
99127
100-
`/films?language=mandarin&maxLength=99...`
128+
/films?language=mandarin&maxLength=99...
129+
130+
##### /language
101131
102-
#####/language
103132
* name
104133
105134
/language?name=english...
106135
107-
##Admin routes
136+
## Admin routes
137+
108138
Non-public (accessible only to application's admins) part of the API has 2 routes:
109139
* **/user** - provides access to users data
110140
* **/admin** - provides access to mechanisms of user management
111141
112142
Operations on these routes don't subtract from your usage limit.
113143
114-
###User
115-
Every user is created with
116-
* role - _user_ (standard user) or _admin_ (administrator),
117-
* name,
118-
* access token,
119-
* usage limit.
120-
121-
After _limit_ requests, every user has to get his limit renewed by an admin.
122-
123-
###Standard user
124-
Can access all **public** routes of the API in terms of his usage limits.
125-
126-
###Administrator
127-
Can access **all routes** of the API in terms of his usage limits and has ability to:
128-
* access all users' data,
129-
* add new users,
130-
* delete current users,
131-
* renew current users' usage limits.
144+
### GET Parameters
132145
133-
###GET Parameters
146+
##### /user
134147
135-
#####/user
136148
* as well as in public API, you can order and paginate the results as well as get multiple results
137149
by listing many ids
138150
@@ -156,7 +168,7 @@ by listing many ids
156168
/user?filter=noaccess...
157169
158170
159-
#####/admin
171+
##### /admin
160172
* action
161173
* add
162174
@@ -176,7 +188,7 @@ You can modify multiple records within one request, for example:
176188
/admin?action=renew&id=1,2,4,8&limit=16,32,64,128
177189
178190
179-
##Credits
191+
## Credits
180192
Thanks to [@math-g](https://github.com/math-g) for porting Sakila (sample MySQL database) to H2 dialect.
181193
182194

0 commit comments

Comments
 (0)