Git Product home page Git Product logo

nodeapi's Introduction

Node API for HackerBay

A simple stateless microservice in Nodejs to demonstrate jwt, json patching and thumbnail generation.

Getting Started

Please follow the guidelines below to set up a copy of this project locally on your machine for development and testing purposes.

First steps

Your can get a copy of this project by using the;

  • git clone command, or the download zip alternative provided on github

Using the terminal, move into the root folder of this project and then run

npm install

to install required dependencies.

Furthermore

A secret variable is required for the token generation at login. Therefore, on your project directory:

  • Create an env file
  • Inside .env file, type the following :
SECRET="<secret>"

N/B: The secret variable can be any text of your choice

Testing

To start the API server run

npm start

You can then start making requests via postman.

To test the application on your local machine, run

npm test

To test the application with code-coverage, run

npm test-with-coverage

A code coverage report will be seen on your console.

API Endpoints

Login

Request body should contain username and password; the API will return a token for the user which will be used for future requests to the server.

  • Sample Request: { "username": "Any name", "password": "Any password" }
  • Sample Response: { "success": true, "user": "Your username", "token": "The generate web token"
    }
  • Note: Any username/password combination is accepted, since this it just a mock authentication service*

JSON Patch

This endpoint accepts two parameters (document and patch) which are JSON objects.

  • Sample Request: { "document": { "baz": "qux", "foo": "bar" }, "patch": [ { "op": "replace", "path": "/baz", "value": "julius" } ] }
  • Sample Response: { "success": true, "data": { "baz": "julius", "foo": "bar" } }
  • Note: Set token equals the token received at login

Thumbnail Generation

This endpoint accepts an image url, generates a 50x50 thumbnail image and returns it to the user.

Modules used

Author

  • Okeke Chekwube Julius - Cheks

nodeapi's People

Contributors

chekwube avatar

Forkers

clementol

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.