A simple image server that uses REST APIs to register/login user and lets him/her upload images to it.
Returns json data about the registered user.
-
URL
/register
-
Scope
PUBLIC
-
Method:
POST
-
URL Params
None
-
Data Params
email: String
password: String
-
Success Response:
- Code: 200
Content:{ "id": 1, "email": "[email protected]", "password": "some_password", "firstName": "some_name", "lastName": "some_last_name" }
- Code: 200
-
Error Response:
- Code: 400 BAD REQUEST
Content:{ "message": "Username has already been taken." }
- Code: 400 BAD REQUEST
-
Sample Call:
curl --location --request POST 'localhost/register' \ --form 'email=EMAIL' \ --form 'password=PASSWORD'
Returns json data about the logged user, without password and with a webtoken.
-
URL
/login
-
Scope
PUBLIC
-
Method:
POST
-
URL Params
None
-
Data Params
email: String
password: String
-
Success Response:
- Code: 200
Content:{ "id": 1, "email": "a", "firstName": "a", "lastName": "", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjEsImlhdCI6MTU5OTMxOTcyMCwiZXhwIjoxNTk5MzM3NzIwfQ.jlvpehyhoAFaeQFde_W80NwbTZktuSaK7emqUyVdDT8" }
- Code: 200
-
Error Response:
- Code: 400 BAD REQUEST
Content:{ "message": "Username or password is incorrect" }
- Code: 400 BAD REQUEST
-
Sample Call:
curl --location --request POST 'localhost/login' \ --form 'email=EMAIL' \ --form 'password=PASSWORD'
Returns json data about the all the images stored.
-
URL
/images
-
Scope
PRIVATE
-
Method:
GET
-
URL Params
None
-
Data Params
None
-
Success Response:
- Code: 200
Content:[ {"id":0,"image_name":"test.png","date":"Sat Sep 01 1963 17:25:58 GMT+0200 (Central European Summer Time)"}, ... {"id":1231,"image_name":"file.png","date":"Sat Sep 02 1963 17:25:58 GMT+0200 (Central European Summer Time)"} ]
- Code: 200
-
Sample Call:
curl --location --request GET 'localhost/images'
Returns json data about the all the users stored.
-
URL
/users
-
Scope
PRIVATE
-
Method:
GET
-
URL Params
None
-
Data Params
None
-
Success Response:
- Code: 200
Content:[ {"id":0,"email":"test","firstName":"Test","lastName":"User"}, ... {"id":1213,"email":"abc","firstName":"abc","lastName":"abc"} ]
- Code: 200
-
Sample Call:
curl --location --request GET 'localhost/users'
Returns json data about the uploaded image.
-
URL
/images/uploadImage
-
Scope
PRIVATE
-
Method:
POST
-
URL Params
None
-
Form Params
image: File
-
Success Response:
- Code: 200
Content:{ "id":1121, "user":4941, "image_name":"_g0p7akqke - image.png", "date":"2020-09-05T15:35:53.073Z" }
- Code: 200
-
Sample Call:
curl --location --request POST 'localhost/images/uploadImage' \ --header 'Authorization: Bearer webtoken' \ --form 'image=@/Users/example/folder/image.png'
Returns specified image if present.
-
URL
/images/:imageId
-
Scope
PRIVATE
-
Method:
POST
-
URL Params
imageId: int
-
Form Params
None
-
Success Response:
- Code: 200
Content: Image
- Code: 200
-
Error Response:
- Code: 400 BAD REQUEST
Content:{ "message": "Image does not exist" }
OR
- Code: 500 INTERNAL SERVER ERROR
Content:{ "message": "Server was unable to retrieve the image." }
- Code: 400 BAD REQUEST
-
Sample Call:
curl --location --request GET 'localhost/images/1123' \ --header 'Authorization: Bearer webtoken'
Returns json data about every image that a specified user has uploaded.
-
URL
/images/search
-
Scope
PRIVATE
-
Method:
POST
-
URL Params
None
-
Form Params
user: int
-
Success Response:
- Code: 200
Content:[ {"id":0, "image_name":"test.png", "user":1, "date":"Sat Sep 05 2020 17:42:14 GMT+0200 (Central European Summer Time)"}, ... {"id":1, "user":1, "image_name":"_4wljyxeuj - image.png", "date":"2020-09-05T15:45:49.985Z"} ]
- Code: 200
-
Error Response:
- Code: 400 BAD REQUEST
Content:{ "message": "No image of ${user} were found" }
- Code: 400 BAD REQUEST
-
Sample Call:
curl --location --request GET 'localhost/images/search' \ --header 'Authorization: Bearer webtoken' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'user=111111'
Navigate to cloned repository
npm install
to install the required dependencies
npm test
for nodemon process intended for development process
npm start
for production