Code Monkey home page Code Monkey logo

micronomicon's Introduction

micronomicon

Codacy Badge

The backend for the micro-learning app micronomicon.

Usage:

There are many available tags. User subscribes to new tags and gets a micron to read/watch on those topics. A Micron is a random resource on the given topics.

Endpoints

method endpoint does
POST /register Register a user
POST /login Log a user in
POST /logout Logs the user out
GET /users/me Get the user
GET /users/me/tags Get the user's tags
POST /users/me/tags Add new tags to the user tags
DELETE /users/me/tags Delete tags from the user tags
GET /users/me/microns Get a micron for the user
GET /tags Get all the available tags

/register

Expand

Method : POST

Body

{
    "email": "[email protected]",
    "username": "jane",
    "name": "Jane Doe",
    "password": "abc-12345"
}

Response

{
    "message": "Created the user"
}

/login

Expand

Method : POST

Body

{
    "username" : "jane",
    "password" : "abc-12345"
}

Response

{
    "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTY1NzE2MjIsImlhdCI6MTU5NjU2NDQyMiwidXNlcm5hbWUiOiJvd2FyeSJ9.CS7osQC8bQihpG7nQKWqUvGQysiB9Y0lkV7tdXSoS-o"
}

/logout

Expand

Method : POST

Headers

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTY1NzE2MjIsImlhdCI6MTU5NjU2NDQyMiwidXNlcm5hbWUiOiJvd2FyeSJ9.CS7osQC8bQihpG7nQKWqUvGQysiB9Y0lkV7tdXSoS-o

Response

{
    "message": "Successfully logged out"
}

/users/me

Expand

Method : GET

Headers

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTY1NzE2MjIsImlhdCI6MTU5NjU2NDQyMiwidXNlcm5hbWUiOiJvd2FyeSJ9.CS7osQC8bQihpG7nQKWqUvGQysiB9Y0lkV7tdXSoS-o

Response

{
    "username": "jane",
    "name": "Jane Doe",
    "email": "[email protected]",
    "tags": {
        "tags": [
            {
                "name": "c"
            },
            {
                "name": "react"
            },
            {
                "name": "python"
            }
        ],
        "size": 3
    }
}

/users/me/tags : GET

Expand

Method : GET

Headers

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTY1NzE2MjIsImlhdCI6MTU5NjU2NDQyMiwidXNlcm5hbWUiOiJvd2FyeSJ9.CS7osQC8bQihpG7nQKWqUvGQysiB9Y0lkV7tdXSoS-o

Response

{
    "tags": [
        {
            "name": "c"
        },
        {
            "name": "react"
        },
        {
            "name": "python"
        }
    ],
    "size": 3
}

/users/me/tags : POST

Expand

Method : POST

Headers

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTY1NzE2MjIsImlhdCI6MTU5NjU2NDQyMiwidXNlcm5hbWUiOiJvd2FyeSJ9.CS7osQC8bQihpG7nQKWqUvGQysiB9Y0lkV7tdXSoS-o

Body

{
    "ids": ["c", "angular", "react"]
}

Response

{
    "message": "Successfully added the tags"
}

/users/me/tags : DELETE

Expand

Method : DELETE

Headers

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTY1NzE2MjIsImlhdCI6MTU5NjU2NDQyMiwidXNlcm5hbWUiOiJvd2FyeSJ9.CS7osQC8bQihpG7nQKWqUvGQysiB9Y0lkV7tdXSoS-o

Body

{
    "ids": ["c", "angular", "react"]
}

Response

{
    "message": "Successfully removed the tags"
}

/tags

Expand

Method : GET

Headers

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTY1NzE2MjIsImlhdCI6MTU5NjU2NDQyMiwidXNlcm5hbWUiOiJvd2FyeSJ9.CS7osQC8bQihpG7nQKWqUvGQysiB9Y0lkV7tdXSoS-o

Response

{
    "tags": [
        {
            "name": "c"
        },
        {
            "name": "react"
        },
        {
            "name": "groovy"
        }
    ]
}

/users/me/microns

Expand

Method : GET

Headers

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTY1NzE2MjIsImlhdCI6MTU5NjU2NDQyMiwidXNlcm5hbWUiOiJvd2FyeSJ9.CS7osQC8bQihpG7nQKWqUvGQysiB9Y0lkV7tdXSoS-o

Response

{
    "URL": "https://learnxinyminutes.com/docs/python/",
    "Title": "Python"
}

Running tests

To run all the test, issue the following command:

docker-compose -f docker-compose-test.yml up

micronomicon's People

Contributors

rhaeguard avatar

Watchers

 avatar

micronomicon's Issues

Set an expiry date for jwt tokens that are persisted

When a user logs in, a token is created.
When the user logs out, the token is deleted

But if the user logs in without logging out, it introduces dangling jwt tokens in the database.

MongoDB has the functionality to put an expiry date on documents.

Improve logging

Improve logging by adding more useful log messages.

Consider other log libraries than the default one (e.g. logrus)

Test data access layers

Test data access layers that interact with mongodb

  • they can be integration tests where a mongodb instance should be run
  • find a way to mock the mongodb structs/interfaces

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.