Git Product home page Git Product logo

koa-challenge's Introduction

koa-challenge

Build Status

js-semistandard-style

Challenge

  • Simple model on mongoose
  • REST CRUD (create, read, update, delete) for the model created using koajs
  • GraphQL Type for the model created, and expose it in a GraphQL endpoint
  • Tests using [Jest]
  • Authentication JWT
  • Docker support
$ nvm use 8.6.0
$ npm install

Starting MongoDB server

$ docker run --name mongo -d -p 27017:27017 mongo
$ npm start
$ npm test

Docker

$ docker build --no-cache -t challenge .
$ docker run -d --name challenge -p 8080:3000 challenge

API Documentation

POST /v1/login

  • Method: POST

  • Endpoint: /v1/login

  • Input: The Content-Type HTTP header should be set to application/json

    {
      "user":"koa",
      "password": "password"
    }
  • Responses:

    {
      "token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYWRtaW4iLCJpYXQiOjE1MDY5NDg2MDZ9.Q-VI1CKFXYf58TX7p9RV-NSyDR6vAZc6JEO58SIXBrs",
      "message": "Successfully logged in!"
    }

POST /v1/tasks

  • Method: POST

  • Endpoint: /v1/tasks

  • Input: The Content-Type HTTP header should be set to application/json and Authorization Bearer TOKEN

    {
        "description": "API",
        "type": "backend"
    }
  • Responses:

    {
        "__v": 0,
        "description": "API",
        "type": "backend",
        "_id": "59d23e3ff3ecdd28a4859675"
    }

GET /v1/tasks

  • Method: GET
  • Endpoint: /v1/tasks
  • Input: HTTP header should be set Authorization Bearer TOKEN
  • Responses:
    [{
        "__v": 0,
        "description": "API",
        "type": "backend",
        "_id": "59d23e3ff3ecdd28a4859675"
    }]

GET /v1/tasks/:id

  • Method: GET
  • Endpoint: /v1/tasks/:id
  • Input: HTTP header should be set Authorization Bearer TOKEN
  • Responses:
    {
        "__v": 0,
        "description": "API",
        "type": "backend",
        "_id": "59d23e3ff3ecdd28a4859675"
    }

PUT /v1/tasks/:id

  • Method: PUT

  • Endpoint: /v1/tasks/:id

  • Input: The Content-Type HTTP header should be set to application/json and Authorization Bearer TOKEN

    {
        "description": "Database",
        "type": "DBA"
    }
  • Responses:

    {
        "_id": "59d23e3ff3ecdd28a4859675",
        "description": "Database",
        "type": "DBA",
        "__v": 0
    }

DELETE /v1/tasks/:id

  • Method: DELETE
  • Endpoint: /v1/tasks/:id
  • Input: HTTP header should be set Authorization Bearer TOKEN
  • Responses:
    {
        "ok": true
    }

GET /public/graphql

  • Method: GET
  • Endpoint: /public/graphql?query={task{id,type,description}}
  • Responses:
    {
        "data":{
            "task":[
                {
                    "id": "59d2410af3ecdd28a4859676",
                    "type": "backend",
                    "description": "API"
                }
            ]
        }
    }

GET /public/graphql

  • Method: GET
  • Endpoint: /public/graphql?query={task{id,type}}
  • Responses:
    {
        "data":{
            "task":[
                {
                    "id": "59d2410af3ecdd28a4859676",
                    "type": "backend"
                }
            ]
        }
    }

GET /public/graphql

  • Method: GET
  • Endpoint: /public/graphql?query={task{type}}
  • Responses:
    {
        "data":{
            "task":[
                {
                    "type": "backend"
                }
            ]
        }
    }

GET /public/graphql

  • Method: GET
  • Endpoint: /public/graphql?query={task{description}}
  • Responses:
    {
        "data":{
            "task":[
                {
                    "description": "API"
                }
            ]
        }
    }

koa-challenge's People

Contributors

fernandocagale avatar

Stargazers

João Marins avatar Rodrigo Oler avatar Rafael Turk avatar

Watchers

James Cloos avatar  avatar

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.