Code Monkey home page Code Monkey logo

dm_jc_test_registration_api's Introduction

Dailymotion - JC Test - Registration API

  1. Technical Stack
  2. How to build and launch containers
  3. Services
    1. Registration Service
    2. Activation Service
  4. Tests
  5. Architecture Diagrem

Technical Stack

  • PHP 7.4
  • Symfony LTS 4.4 framework with components: Router, Dependency Injection, Event Dispatcher, dBal (only for DB Connection, no ORM), Twig (for email template)
  • PostgreSQL
  • NGINX

How to build and launch containers

git clone https://github.com/HooK81/dm_jc_test_registration_api.git
cd dm_jc_test_registration_api
docker-compose build
docker-compose up -d
docker-compose exec php composer build

Changing the default HTTP port

Default HTTP port used is 8080.
It is configurable in docker-compose.yml file.

  1. Edit file docker-compose.yml with your favorite text editor Replace 8080 by the port of your choice

  2. Restart containers

docker-compose down 
docker-compose up -d

DB Storage

No volume is configured for DBMS. So all data are lost when container is removed.

Services

Registration Service

About email

The registration email containing the activation code is not actualy send.
It is logged into container's STDOUT.

You can retrieve it in jc_php container logs with following command:

docker logs --tail 20 -f jc_php

The log about activation code email looks like :

[2021-01-21 21:28:40] mailer.INFO: Activation code for [email protected] is 5302

Call Service

The registration service is available on following endpoint:
[POST]: http://127.0.0.1:8080/api/users/v1/register

A valid cURL example is :

curl -i -X POST \
   -H "Content-Type:application/json" \
   -d \
'{
  "email": "[email protected]",
  "password": "password"
}' \
 'http://127.0.0.1:8080/api/users/v1/register'

Reponse will be something like :

HTTP 200/OK
{
  "id": 1,
  "email": "[email protected]",
  "registered_at": "2021-01-21 21:28:40",
  "activated": false,
  "activation_code_expire_at": "2021-01-21 21:29:40"
}

Activation Service

Call Service

The activation service is available on following endpoint:
[PUT]: http://127.0.0.1:8080/api/users/v1/activate/{activation_code}
CAUTION: HTTP Basic Auth is required

A valid cURL example is :

curl -i -X PUT -v -u [email protected]:password \
   'http://127.0.0.1:8080/api/users/v1/activate/CODE'

Be sure to replace, EMAIL and PASSWORD with values provided in registration service.
Also replace CODE by activation code.

Reponse will be something like :

HTTP 200/OK
{
  "id": 1,
  "email": "[email protected]",
  "registered_at": "2021-01-21 21:28:40",
  "activated": true,
  "activated_at": "2021-01-21 21:29:05"
}

Running tests

To run tests, you can use following command:

docker-compose exec php composer tests

With HTML coverage report

docker-compose exec php composer tests-coverage

The HTML report should be generated into a folder named coverage

The current test suite contains 93 tests with 211 assertions for 100% code coverage.

Architecture Diagram

Architecture Diagram

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.