About • Features • How it works • Tech Stack • Author • License
Dart REST API is just an little project made with the purpose of study back-end development with Dart.
- User register
- User auth with JsonWebToken
- User account update
- User account delete
- CRUD operations with Expressions
- Only logged users have authorization to access data from "expressions" endpoint
This API has only two endpoints:
- Auth
- Expressions
Note: To realize actions as an authenticated user the request header must have the field "Authorization" with the following value "Bearer {accessToken}", where {accessToken} should be replaced with your auth token.
This endpoint handle all actions related to an user:
- Register
- Login/Logout
- Update Info
- Delete Account
Description: Register an user on system. On success, returns an answer with status code 201 and a string with a success message. In case this process fail, then returns an answer with status 4XX and a string with a better description of the problem.
Examples:
-
Request address:
http://localhost:8080/auth/register
-
Request body::
{ "username" : "Dobby", "email" : "[email protected]", "password" : "#FreeElves" }
-
Answer:
User successfully registered
Description: Performs the user login on system. On success, returns an answer with status code 200 and a JSON with two 'tokens', being one for auth (expires in 15 minutes) and the other to renew the first one (expires in 30 minutes). In case this process fail, then returns an answer with status 4XX and a string with a better description of the problem.
Examples:
-
Request address:
http://localhost:8080/auth/login
-
Request body:
{ "email" : "[email protected]", "password" : "#FreeElves" }
-
Answer:
{ "token" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2NDI3NzEzMDYsImV4cCI6MTY0Mjc3MzEwNiwic3ViIjoiMSIsImlzcyI6ImxvY2FsaG9zdCIsImp0aSI6IjA2ZmVhZmI5LTA4MTEtNGRhZS05YTljLTc5NjBmNzVlYTZhMSJ9.76LagMOKPVgY0-ZScMDhlRjpwvbXESqUCGDhbbPPbQQ", "refreshToken" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2NDI3NzEzMDYsImV4cCI6MTY0Mjc3NDkwNiwic3ViIjoiMSIsImlzcyI6ImxvY2FsaG9zdCIsImp0aSI6IjA2ZmVhZmI5LTA4MTEtNGRhZS05YTljLTc5NjBmNzVlYTZhMSJ9.A4YkORrXTZOjnANhisPRSAED_PLgLTA6biIVkSz11pk" }
Description: Renew an user token on system. On success, returns an answer with status code 200 and a JSON with two 'tokens', being one for auth (expires in 15 minutes) and the other to renew the first one (expires in 30 minutes). In case this process fail, then returns an answer with status 4XX and a string with a better description of the problem.
Examples:
-
Request address:
http://localhost:8080/auth/refreshToken
-
Request body:
{ "refreshToken" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2NDI3NzEzMDYsImV4cCI6MTY0Mjc3NDkwNiwic3ViIjoiMSIsImlzcyI6ImxvY2FsaG9zdCIsImp0aSI6IjA2ZmVhZmI5LTA4MTEtNGRhZS05YTljLTc5NjBmNzVlYTZhMSJ9.A4YkORrXTZOjnANhisPRSAED_PLgLTA6biIVkSz11pk" }
-
Answer:
{ "token" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2NDI3NzI1MDMsImV4cCI6MTY0Mjc3NDMwMywic3ViIjoiMSIsImlzcyI6ImxvY2FsaG9zdCIsImp0aSI6Ijc0ODYyMzUzLWQwZmUtNDk4OC1iOWQwLWZiN2YyNTJhZjI3YyJ9.QEqezAmz333iQNVpsWG6UZUidLDOKHgx2KWyc-lW9KI", "refreshToken" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2NDI3NzI1MDMsImV4cCI6MTY0Mjc3NjEwMywic3ViIjoiMSIsImlzcyI6ImxvY2FsaG9zdCIsImp0aSI6Ijc0ODYyMzUzLWQwZmUtNDk4OC1iOWQwLWZiN2YyNTJhZjI3YyJ9.SjmSc23465l35-kJQneEfFe8mTohv9G9FSiZ0-2oFIM" }
Description: Performs an user logout on system and revoke their renew token. On success, returns an answer with status code 200 and a string with a success message. In case this process fail, then returns an answer with status 4XX and a string with a better description of the problem (probably unauthorized user exception).
Examples:
-
Request address:
http://localhost:8080/auth/logout
-
Answer:
Successfully logged out
Description: Updates an user info on system. On success, returns an answer with status code 200 and a string with a success message. In case this process fail, then returns an answer with status 4XX and a string with a better description of the problem.
Examples:
-
Request address:
http://localhost:8080/auth/updateInfo
-
Request body:
{ "username" : "Free Dobby", "email" : "[email protected]", "password" : "ThanksHarry" }
-
Answer
User information successfully updated
Description: Deletes an user on system and revokes their renew token. On success, returns an answer with status code 200 and a string with a success message. In case this process fail, then returns an answer with status 4XX and a string with a better description of the problem (probably unauthenticated user exception).
Examples:
-
Request address:
http://localhost:8080/auth/deleteAccount
-
Answer:
User successfully deleted
This endpoint make it possible to an authenticated user perform CRUD operations on Expressions.
Description: Creates an expression on system. On success, returns an answer with status code 201 and a JSON with the created expression. In case this process fail, then returns an answer with status 4XX and a string with a better description of the problem.
Examples:
-
Request address:
http://localhost:8080/expressions
-
Request body::
{ "expression" : "Go on a wild goose chase", "meaning" : "To do something pointless" }
-
Answer:
{ "id" : 1, "expression" : "Go on a wild goose chase", "meaning" : "To do something pointless", "lastUpdate" : "2022-01-21T13:58:06.578517" }
Description: Get all expressions on system. On success, returns an answer with status code 200 and a JSON with a list of expressions. In case this process fail, then returns an answer with status 4XX and a string with a better description of the problem.
Examples:
-
Request address:
http://localhost:8080/expressions
-
Answer:
[ { "id" : 0, "expression" : "Get a taste of your own medicine", "meaning" : "Get treated the way you've been treating others (negative)", "lastUpdate" : "2022-01-19T19:34:09.244124" }, { "id" : 1, "expression" : "Go on a wild goose chase", "meaning" : "To do something pointless", "lastUpdate" : "2022-01-21T13:58:06.578517" } ]
Description: Get an expression on system. On success, returns an answer with status code 200 and a JSON with the referred expression. In case this process fail, then returns an answer with status 4XX and a string with a better description of the problem.
Examples:
-
Request address:
http://localhost:8080/expressions/1
-
Answer:
{ "id" : 1, "expression" : "Go on a wild goose chase", "meaning" : "To do something pointless", "lastUpdate" : "2022-01-21T13:58:06.578517" }
Description: Updates an expression on system. On success, returns an answer with status code 200 and a JSON with the updated expression. In case this process fail, then returns an answer with status 4XX and a string with a better description of the problem.
Examples:
-
Request address:
http://localhost:8080/expressions/1
-
Request body::
{ "expression" : "Go on a wild goose chase", "meaning" : "Bla bla bla", }
-
Answer:
{ "id" : 1, "expression" : "Go on a wild goose chase", "meaning" : "Bla bla bla", "lastUpdate" : "2022-01-21T13:59:06.384333" }
Description: Deletes an expression on system. On success, returns an answer with status code 204. In case this process fail, then returns an answer with status 4XX and a string with a better description of the problem.
Examples:
-
Request address:
http://localhost:8080/expressions/1
Before you begin, you will need to have Docker installed and configured in your machine.
From the root folder run docker-compose and create the necessary containers.
$ docker-compose up -d
The following tools were used in the construction of the project:
- Editor: Visual Studio Code → Plugin: Flutter, Dart
This project is under the license MIT.
Made with love by Hericles Koelher