Skip to content

alex223125/staffomatic_user_management

Folders and files

NameName
Last commit message
Last commit date
Jul 20, 2021
Sep 14, 2022
Jul 20, 2021
Sep 13, 2022
Sep 13, 2022
Jul 20, 2021
Jul 20, 2021
Jul 20, 2021
Sep 14, 2022
Jul 20, 2021
Jul 20, 2021
Jul 20, 2021
Jul 20, 2021
Jul 20, 2021
Sep 14, 2022
Sep 14, 2022
Sep 21, 2022
Jul 20, 2021
Jul 20, 2021
Sep 21, 2022
Sep 21, 2022
Sep 13, 2022
Sep 21, 2022

Repository files navigation

Developed features:

an authenticated user, should be able able to archive, unarchive and delete an existing user
an authenticated user, should not be able to archive/unarchive/delete himself
the api should return the users which are archived/unarchived based on a filter parameter
we do want to keep track when these operations happened and which user did it
after archive/unarchive/delete of a user we want to inform that user via email, push notifications and/or webhooks
conform to the https://jsonapi.org/ specs

To run application:

bunlde install
rails s 

Staffomatic User Management

This is our Lekker Rails-API 🚀

Rspec

Get it up and running

start up docker

$ docker-compose up
Building api
Step 1/10 : FROM ruby:2.6.6-alpine
...
server --help` for more startup options
api_1    | Puma starting in single mode...
api_1    | * Puma version: 5.2.0 (ruby 2.6.6-p146) ("Fettisdagsbulle")
api_1    | *  Min threads: 5
api_1    | *  Max threads: 5
api_1    | *  Environment: development
api_1    | *          PID: 1
api_1    | * Listening on http://0.0.0.0:3189
api_1    | Use Ctrl-C to stop

use --build api if you changed e.g. Gemfile

$ docker-compose up --build api

Check if app is running, expect a ActiveRecord::NoDatabaseError:

$ open http://localhost:3189
# or
$ curl http://localhost:3189

Follow the logs

$ tail -f log/development.log
# or for specs:
$ tail -f log/test.log

Prepare database

$ docker-compose run api bundle exec rake db:prepare
  Creating staffomatic_user_management_api_run ... done
  Created database 'staffomatic_user_management_development'
  Created database 'staffomatic_user_management_test'

Run specs

$ docker-compose run api bundle exec rspec

if you see a migration error, you might need to run:

$ docker-compose run -e RAILS_ENV=test api bundle exec rake db:prepare

Cleanup Docker

Stop the container(s):

$ docker-compose down

Delete all containers:

$ docker rm -f $(docker ps -a -q)

Delete all volumes:

$ docker volume rm staffomatic_user_management_db_data
# OR remove all
$ docker volume rm $(docker volume ls -q)

API Documentation

Signup User

(POST /signup)
$ curl --request POST --header "Content-Type: application/json" \
          http://localhost:3189/signup --data \
          '{"data": {"attributes": {"email": "admin@easypep.de", "password": "welcome", "password_confirmation": "welcome"}}}'

Authenticate User

(POST /authentications)
$ curl --request POST --header "Content-Type: application/json" \
          http://localhost:3189/authentications --data \
          '{"authentication": {"email": "admin@easypep.de", "password": "welcome"}}'

List Users

(GET /users)
$ curl --header \
        "Authentication: Bearer JWT_TOKEN" \
        --header "Content-Type: application/json" \
        http://localhost:3189/users

About

Code challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages