This repository houses the implementation of a File Verification API. The API is built using Laravel and allows authenticated users to send a JSON file and receive a verification result as a response. Please refer to this documentation for more information about the requirements of the API.
- Authentication system for users.
- Endpoint for verifying uploaded files with multiple verification logics.
- valid issuer
- valid recipient
- valid signature
- Scalable architecture to facilitate easy addition of new verification logics.
- git
- docker
- Clone this repository.
$ git clone https://github.com/SarahTeoh/file-verification-api.git
- Navigate to the project directory
$ cd file-verification-api
- Create
.env
file$ cp .env.example .env
- Update
.env
file content- update the environment variables such as database credentials and port number.
- the default database settings are as follows:
DB_CONNECTION=mysql DB_HOST=mysql DB_PORT=3306 DB_DATABASE=laravel
- you may need to change the port number
3306
if any port number conflicts occur in your environment. In such case, you should also change the port binding in docker-compose.yaml accordingly.
- Create the
.env.testing
file for testing environment$ cp .env .env.testing
- Update the
.env.testing
fileDB_CONNECTION=sqlite DB_DATABASE=:memory:
- Build and run the application
At this point, you should see something like this in your terminal:
$ docker-compose up -d --build // build the docker containers $ docker-compose exec app bash // access the docker container $ php artisan serve
This means that application server is running.INFO Server running on [http://127.0.0.1:8080].
-
access the docker container
$ docker-compose exec app bash
-
Create user using artisan command
$ php artisan users:create
Follows the instructions. For example:
root@575cd53c4ac7:/var/www/html# php artisan users:create Name of the new user: > user Email of the new user: > [email protected] Password of the new user: > ******** User [email protected] created successfully
-
Access the API documentation at
http://127.0.0.1:8080/api/v1/docs
-
Connect to the API using POSTMAN as documented in the documentation
HTTP Verbs | Endpoints | Action |
---|---|---|
POST | /api/v1/login | To login and get API token |
POST | /api/v1/verify | To verify a file |
Note: There is no /signup
endpoint to prevent unauthorized signups. The first user can be created using command-line tools.