Skip to content

Adgoal/test-interview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introducing

The main aim of this test task is to create small API, with token authentication and fetching data from DB.

All constants value writing below in UPPER_CASE you can find in .env file.

Install

We have already prepared docker environment with nginx, php 7.4 and mysql database. To run this project you only need to run command below.

make install

If you not familiar with makefile or you haven't install it on you machine you can build docker manually.

Tasks

You need to implement two endpoint: authentication and fetching data

Auth endpoint:

POST /api/auth

This endpoint must receive json object

{
  "user": USER_LOGIN,
  "password": USER_PASSWORD
}

Please, check if the auth data correct (do not save user in DB, use simple string comparison) and if yes return to client this json object:

{
  "token": "<token_value>"
}

where token_value is the base64 encoded string which consist of 2 strings concatenated by dot .; Example:

1646804985.b62e3d1b1c0cdef60f16dbae068dcc0ac7422ff51170fc33498ffa94880bd190

The first part is the timestamp when request was made.
The second part is SHA256 HMAC hash of the timestamp value computed with APP_SECRET_KEY

Data endpoint

GET /api/stats

All request to this endpoint must contain header:

Authorization: Bearer <token_value>

Token must be valid during TOKEN_LIFETIME seconds. If token is invalid or expired return 403 http code.

In adgoal database you can find table programs. The schema of this table:

create table programs (
  id int NOT NULL AUTO_INCREMENT,
  network_id int,
  active int,
  rate int,
  PRIMARY KEY (id)
);

Please, select without joins and subqueries ALL networks which has active programs and ALL OF THEM has rate > 10.

Return data as json array.

P.S.

It would be good if your implementation would allow you to add new endpoints quickly and easy. Please, do not use any frameworks. The main aim of this project is to look at you style and architectural approach. If you have any question or you need some clarification about this task you are welcome to write us by email [email protected]

When you'll be ready create pull request. May the Force be with you.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published