2023-10-15 18:54:06 +05:30
|
|
|
WARNING:-
|
|
|
|
Do NOT use this api for ANY reason EXCEPT if usage is ONLY local, i.e.,
|
|
|
|
this api is NOT built for usage over an external network and doing so
|
|
|
|
WILL NOT BE SECURE
|
|
|
|
|
|
|
|
Note:- Server throws 405 METHOD NOT ALLOWED if the url is mistyped
|
2023-10-15 12:33:48 +05:30
|
|
|
_____________________
|
|
|
|
Login:-
|
|
|
|
|
2023-10-15 18:54:06 +05:30
|
|
|
WARNING:-
|
|
|
|
If login is used when another user is logged in,
|
|
|
|
the original user is automatically logged out.
|
2023-10-15 12:33:48 +05:30
|
|
|
|
2023-10-15 18:54:06 +05:30
|
|
|
URL:- /login
|
|
|
|
Method:- POST
|
2023-10-15 12:33:48 +05:30
|
|
|
Data Type:- Form Data
|
|
|
|
Data content:- {
|
|
|
|
user_name: "<user name>",
|
|
|
|
password: "<password>"
|
|
|
|
}
|
|
|
|
|
|
|
|
Response:-
|
|
|
|
200 OK:-
|
|
|
|
Data:- No
|
|
|
|
Note:- Assume login completed.
|
|
|
|
400 Bad Request:-
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- user_name or password not given a Form Data.
|
|
|
|
Data:- What is missing will be mentioned.
|
|
|
|
403 Forbidden:-
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- user_name or password is wrong, can display the response data to user.
|
2023-10-15 13:17:00 +05:30
|
|
|
Data:- What is wrong will be mentioned, text that can be displayed on the screen.
|
|
|
|
|
|
|
|
Example:-
|
2023-10-15 18:54:06 +05:30
|
|
|
formData = new FormData()
|
|
|
|
formData.append('user_name', 'John')
|
|
|
|
formData.append('password', 'John123')
|
2023-10-15 13:17:00 +05:30
|
|
|
fetch(
|
|
|
|
"/login",
|
|
|
|
{
|
|
|
|
body: formData,
|
|
|
|
method: "post"
|
|
|
|
}
|
2023-10-15 18:54:06 +05:30
|
|
|
)
|
2023-10-15 13:17:00 +05:30
|
|
|
This will give a response status 200 with no data if login is done.
|
|
|
|
This will return a 403 if the user gave wrong name or password.
|
|
|
|
_____________________
|
|
|
|
|
|
|
|
|
2023-10-15 18:54:06 +05:30
|
|
|
_____________________
|
|
|
|
Logout:-
|
|
|
|
URL:- /logout
|
|
|
|
Method:- POST
|
|
|
|
Data:- None
|
|
|
|
|
|
|
|
Response:-
|
|
|
|
200 OK:-
|
|
|
|
Data:- No
|
|
|
|
Note:- Assume Success.
|
|
|
|
403 Forbidden:-
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- User is not logged in.
|
|
|
|
Data:- What is wrong will be mentioned.
|
|
|
|
This text that can be displayed on the screen.
|
|
|
|
_____________________
|
|
|
|
|
|
|
|
|
2023-10-15 13:17:00 +05:30
|
|
|
_____________________
|
|
|
|
Add User:-
|
|
|
|
URL:- /add_user
|
|
|
|
Method:- POST
|
|
|
|
Data Type:- Form Data
|
|
|
|
Data content:- {
|
|
|
|
user_name: "<user name>",
|
|
|
|
password: "<password>"
|
|
|
|
}
|
2023-10-15 18:54:06 +05:30
|
|
|
Note:- Does not login the user
|
2023-10-15 13:17:00 +05:30
|
|
|
|
|
|
|
Response:-
|
|
|
|
200 OK:-
|
|
|
|
Data:- No
|
|
|
|
Note:- Assume success.
|
|
|
|
400 Bad Request:-
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- user_name or password not given a Form Data.
|
|
|
|
Data:- What is missing will be mentioned.
|
|
|
|
403 Forbidden:-
|
|
|
|
Content Type:- text/plain
|
2023-10-15 18:54:06 +05:30
|
|
|
Note:- user_name exists, can display the response data to user.
|
|
|
|
Data:- What is wrong will be mentioned.
|
|
|
|
This text that can be displayed on the screen.
|
2023-10-15 12:33:48 +05:30
|
|
|
|
|
|
|
Example:-
|
2023-10-15 18:54:06 +05:30
|
|
|
formData = new FormData()
|
|
|
|
formData.append('user_name', 'John')
|
|
|
|
formData.append('password', 'John123')
|
2023-10-15 12:33:48 +05:30
|
|
|
fetch(
|
2023-10-15 18:54:06 +05:30
|
|
|
"/add_user",
|
2023-10-15 12:33:48 +05:30
|
|
|
{
|
|
|
|
body: formData,
|
|
|
|
method: "post"
|
|
|
|
}
|
2023-10-15 18:54:06 +05:30
|
|
|
)
|
|
|
|
This will give a response status 200 with no data if a user is added.
|
|
|
|
This will return a 403 if the user gave a existing name.
|
2023-10-15 12:33:48 +05:30
|
|
|
_____________________
|
2023-10-15 14:38:32 +05:30
|
|
|
|
|
|
|
|
|
|
|
_____________________
|
|
|
|
Get Data:-
|
|
|
|
URL:- /get_data
|
|
|
|
Method:- POST
|
|
|
|
Data:- None
|
2023-10-15 18:54:06 +05:30
|
|
|
Prerequisites:- Login
|
2023-10-15 14:38:32 +05:30
|
|
|
|
|
|
|
Response:-
|
|
|
|
200 OK:-
|
2023-10-15 18:54:06 +05:30
|
|
|
Data:- {
|
2023-10-15 14:38:32 +05:30
|
|
|
entry_name: {
|
|
|
|
field_name: field_value
|
|
|
|
}
|
|
|
|
}
|
2023-10-15 18:54:06 +05:30
|
|
|
Content Type:- text/json
|
2023-10-15 14:38:32 +05:30
|
|
|
403 Forbidden:-
|
|
|
|
Data:- Text that can be directly displayed to the user
|
|
|
|
Note:- Not logged in
|
|
|
|
|
|
|
|
|
2023-10-15 18:54:06 +05:30
|
|
|
Example Response:-
|
2023-10-15 14:38:32 +05:30
|
|
|
{
|
|
|
|
"Amazon": {
|
|
|
|
"Username": "Kosh",
|
|
|
|
"Password": "Pass1234"
|
|
|
|
},
|
|
|
|
"Matrix": {
|
|
|
|
"Username": "Kosh",
|
|
|
|
"Email": "kosh@fake.com",
|
|
|
|
"id": "@kosh:matrix.com"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_____________________
|
2023-10-15 18:54:06 +05:30
|
|
|
|
|
|
|
|
|
|
|
_____________________
|
|
|
|
Change Password:-
|
|
|
|
URL:- /change_password
|
|
|
|
Method:- POST
|
|
|
|
Data:- New Password
|
|
|
|
Prerequisites:- Login
|
|
|
|
|
|
|
|
Response:-
|
|
|
|
200 OK:-
|
|
|
|
Data:- None
|
|
|
|
Note:- Assume success
|
|
|
|
400 Bad Request:-
|
|
|
|
Data:- Error text
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- password not given. :<
|
|
|
|
403 Forbidden:-
|
|
|
|
Data:- Text that can be directly displayed to the user
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- Not logged in
|
|
|
|
_____________________
|
|
|
|
|
|
|
|
|
|
|
|
_____________________
|
|
|
|
Add entry:-
|
|
|
|
URL:- /add_entry
|
|
|
|
Method:- POST
|
|
|
|
Data:- {
|
|
|
|
entry_name: "<entry_name>",
|
|
|
|
fields: {
|
|
|
|
field_name1: "<field_value1>",
|
|
|
|
field_name2: "<field_value2>",
|
|
|
|
...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Prerequisites:- Login
|
|
|
|
|
|
|
|
Response:-
|
|
|
|
200 OK:-
|
|
|
|
Data:- None
|
|
|
|
Note:- Assume success
|
|
|
|
400 Bad Request:-
|
|
|
|
Data:- Error text
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- entry_name or fields not given or fields cannot be converted to json
|
|
|
|
403 Forbidden:-
|
|
|
|
Data:- Text that can be directly displayed to the user
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- Not logged in or entry_name already exists
|
|
|
|
|
|
|
|
Example:-
|
|
|
|
formData = new FormData()
|
|
|
|
formData.append('entry_name', 'Amazon')
|
|
|
|
formData.append(
|
|
|
|
'fields',
|
|
|
|
JSON.stringify(
|
|
|
|
{
|
|
|
|
"User Name": "Kosh",
|
|
|
|
password: "1234"
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
fetch(
|
|
|
|
"/entry_name",
|
|
|
|
{
|
|
|
|
body: formData,
|
|
|
|
method: "post"
|
|
|
|
}
|
|
|
|
)
|
|
|
|
This will give a response status 200 with no data if the data is entered.
|
|
|
|
This will return a 403 if the user is not logged in or entry_name already exists.
|
|
|
|
_____________________
|
|
|
|
|
|
|
|
|
|
|
|
_____________________
|
|
|
|
Delete Entry:-
|
|
|
|
URL:- /delete_entry
|
|
|
|
Method:- POST
|
|
|
|
Data:- entry_name
|
|
|
|
Prerequisites:- Login
|
|
|
|
|
|
|
|
Response:-
|
|
|
|
200 OK:-
|
|
|
|
Data:- None
|
|
|
|
Note:- Assume success
|
|
|
|
400 Bad Request:-
|
|
|
|
Data:- Error text
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- entry_name not given
|
|
|
|
403 Forbidden:-
|
|
|
|
Data:- Text that can be directly displayed to the user
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- Not logged in or entry_name does not exist
|
|
|
|
_____________________
|
|
|
|
|
|
|
|
|
|
|
|
_____________________
|
|
|
|
Edit Entry Name:-
|
|
|
|
URL:- /edit_entry_name
|
|
|
|
Method:- POST
|
|
|
|
Data:- old_entry_name, new_entry_name
|
|
|
|
Prerequisites:- Login
|
|
|
|
|
|
|
|
Response:-
|
|
|
|
200 OK:-
|
|
|
|
Data:- None
|
|
|
|
Note:- Assume success
|
|
|
|
400 Bad Request:-
|
|
|
|
Data:- Error text
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- old_entry_name or new_entry_name not given
|
|
|
|
403 Forbidden:-
|
|
|
|
Data:- Text that can be directly displayed to the user
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- Not logged in or old_entry_name does not exist or new_entry_name exists
|
|
|
|
_____________________
|
|
|
|
|
|
|
|
|
|
|
|
_____________________
|
|
|
|
Add Field:-
|
|
|
|
URL:- /add_field
|
|
|
|
Method:- POST
|
|
|
|
Data:- entry_name, field_name, field_value
|
|
|
|
Prerequisites:- Login
|
|
|
|
|
|
|
|
Response:-
|
|
|
|
200 OK:-
|
|
|
|
Data:- None
|
|
|
|
Note:- Assume success
|
|
|
|
400 Bad Request:-
|
|
|
|
Data:- Error text
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- entry_name, field_name or field_value are
|
|
|
|
not given or fields cannot be converted to json
|
|
|
|
403 Forbidden:-
|
|
|
|
Data:- Text that can be directly displayed to the user
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- Not logged in or field_name already exists or entry_name does not exist
|
|
|
|
_____________________
|
|
|
|
|
|
|
|
|
|
|
|
_____________________
|
|
|
|
Edit Field Name:-
|
|
|
|
URL:- /edit_field_name
|
|
|
|
Method:- POST
|
|
|
|
Data:- entry_name, old_field_name, new_field_name
|
|
|
|
Prerequisites:- Login
|
|
|
|
|
|
|
|
Response:-
|
|
|
|
200 OK:-
|
|
|
|
Data:- None
|
|
|
|
Note:- Assume success
|
|
|
|
400 Bad Request:-
|
|
|
|
Data:- Error text
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- old_field_name or new_field_name not given
|
|
|
|
403 Forbidden:-
|
|
|
|
Data:- Text that can be directly displayed to the user
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- Not logged in or old_field_name does not exist or new_field_name exists
|
|
|
|
_____________________
|
|
|
|
|
|
|
|
|
|
|
|
_____________________
|
|
|
|
Edit Field Value:-
|
|
|
|
URL:- /edit_field_value
|
|
|
|
Method:- POST
|
|
|
|
Data:- entry_name, field_name, field_value
|
|
|
|
Prerequisites:- Login
|
|
|
|
|
|
|
|
Response:-
|
|
|
|
200 OK:-
|
|
|
|
Data:- None
|
|
|
|
Note:- Assume success
|
|
|
|
400 Bad Request:-
|
|
|
|
Data:- Error text
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- entry_name, field_name or field_value not given
|
|
|
|
403 Forbidden:-
|
|
|
|
Data:- Text that can be directly displayed to the user
|
|
|
|
Content Type:- text/plain
|
|
|
|
Note:- Not logged in or field_name does not exist
|
|
|
|
_____________________
|
|
|
|
|