This is the GovAssist TECH CHALLENGE.
As an Entity, we have added a "URL" model. These are only some of the files used. This will create the DB schema, and seed some dummy info into tables, for a better understanding.
BE AWARE: A MySql server must be installed and running in order to test this challenge. (docker run --name mysql -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=change-me --restart unless-stopped mysql:8)
Files created for MODELS SCHEMA:
Type | Name | Description |
---|---|---|
Model | Url.php | |
Model | User.php |
Type | Name | Description |
---|---|---|
Factory | UrlFactory.php | |
Factory | UserFactory.php |
Type | Name | Description |
---|---|---|
Seeder | UrlSeeder.php | Loads Dummy Urls into DB. |
Type | Name | Description |
---|---|---|
Migration | 2023_08_30_194103_create_url_table.php | |
Migration | 2023_08_30_200537_create_users_table.php |
CHALLENGE:
-
Endpoints for authentication using JWT. Also an endpoint for refreshing the JWT access token. (CSRF sanctrum for cookie not added)
POST api/auths/login ............................................ AuthController@login POST api/auths/logout ........................................... AuthController@logout POST api/auths/refresh .......................................... AuthController@refresh POST api/auths/register ......................................... AuthController@register
-
Endpoints for CRUD URL. It also allows to filter by state.
Example: http://127.0.0.1:8000/api/urls?per_page=25&state=Active Filter for Urls is by State (only added one as an example)
GET|HEAD api/urls ..................................... urls.index › UrlController@index POST api/urls ..................................... urls.store › UrlController@store POST api/urls/state ............................... urls.state.update › UrlController@stateUpdate GET|HEAD api/urls/{url} ............................... urls.show › UrlController@show DELETE api/urls/{url} ............................... urls.destroy › UrlController@destroy GET|HEAD /{url} ....................................... urls.redirect › UrlController@redirect
-
We are using Middlewares for JWT authentication, and to configure JSON responses or VIEWS responses depending on the case.
-
We homogenized the responses for api with a JsonHelper, used in the Global Exception Handler.
-
We have implemented: "php-open-source-saver/jwt-auth": "^2.1", (For JWT auth manipulation) and "veelasky/laravel-hashid": "^3.1" (for hashing the slug automatically)
-
We are using the LARAVEL-HASHID treat in the url model, to map the hash into the slug.
For the FRONT-END vue 3 application.
-
We have added login.
-
We have added registration (with minimun fields).
-
We have added a CREATE and INDEX VIEW for URLS.
-
We have added a simple about screen, to explain the Challenge.
-
We have added a logout functionality.
-
We are using AXIOS for endpoints requests, vuetify 3 for styles framework, and vue 3 with script setup notations.
-
We have created 2 middlewares. 1 to add the JWT on all the neccesary requests. And another one to detect whenever the application is logged out, to push user to login screen.
- clone the repo
git clone https://github.com/iciani/govAssist.git
- cd into cloned repo
cd gobAssist
cd back
- install dependencies
composer install
- Remember to Generate .ENV file.
Parameters here are basic. They can be change regarding environment.
cp .env.example .env
- Validate the Code
./vendor/bin/phplint
./vendor/bin/phpcs -s
php artisan test
- Execute Migrations (This will create all the DATABASE models)
php artisan migrate (you will be asked to create the DB, please type yes)
- Execute Seeders (This will fill in dummy information for testing purposes)
php artisan db:seed (you can execute this command, as many times as you wish. This will be adding new lines)
- Load POSTMAN collection to TEST the ENDPOINTS (Found in this folder BACK)
govassist.postman_collection.json
- Run Schedules (To validate the execution of the command, we have scheduled every minute.)
php artisan schedule:run
- Execute the App in one Terminal
php artisan serve (Being at PWD root of folder BACK)
- If you visit the base url configured (default would be http://localhost:8000) you should now see a welcome screen in /.
- In a new terminal, browse project folder.
cd gobAssist
cd front
- Install dependencies.
npm install
- Validate the Code.
npm run lint
- Run the App.
npm run dev
- Run the Tests.
npx cypress run
- As default, the DB was seeded with Admin User, or you can Register new user.
[email protected] // govassist