Giter Site home page Giter Site logo

categoriesrestapi's Introduction

FLACONI REST API

This service allows us to create RESTful API to manage categories for e-comerce website.

  1. Technical Stack

    . Node.js javascript runtime environment . Express web application REST API framework for Node.js . Sequeize promise based ORM for Node.js . SQLite as databas . POSTMAN REST API test framework . SQLite browser to view the tables(https://sqlitebrowser.org)

  2. Steps for running the service.

2.1 In non-dockerized environment . Download the folder name flaconi on your machine . Go to subfolder named flaconi-svc . Hit the command npm start as simple. This should launch the application with the welcome message, synchronisation of database notifiction as well as message stating that the application is up and running on port 3000

2.1.1 RUN API tests
. Download POSTMAN tool from https://www.getpostman.com/apps

  . Once downloaded open the postman tool.
             . Click Builder tab   

             . In the input box enter the api route url and      press SEND. This should send request to the       REST API routes defined in the application        under flaconi-svc/routes/category folder

 2.1.1.1 CREATE CATEGORY

       . Make POST call to http://localhost:3000/flaconiService/createCategory route from POSTMAN

       . Click on Body option and enter the data to padd to the route in JSON format. For instance 
       {
            "name": "eat lunch",
            "isVisible": true,
            "slug":"lunchee"
         }
       
        .Click on send

       . You could the response by going to the Headers section.

       .Follow section 3 to open database file to see if the record is created.


 2.1.1.2 RETRIEVE CATEGORY BY ID

        . Make GET call to http://localhost:3000/flaconiService/findCategoryById/yourcatgoryId route from POSTMAN

         . You could the response by going to the Headers section.

  2.1.1.3 RETRIEVE CATEGORY BY SLUG

        . Make GET call to http://localhost:3000/flaconiService/findCategoryBySlug/yourslug route from POSTMAN

         . You could the response by going to the Headers section.

  2.1.1.4 UPDATE VISIBLITY STATUS

       . Make POST call to http://localhost:3000/flaconiService/updateVisiblity/yourcategoryId route from POSTMAN

         . In the Body section, provide the "isVisible" : "your value" inside the curly braces 

         . You could the response by going to the Headers section.

   2.1.1.5 RETRIEVE CATEGORIES BY PARENT CATEGORY

        . Make GET call to http://localhost:3000/flaconiService/findCategoriesByParentCategory/yourparentCategory route from POSTMAN

         . You could the response by going to the Headers section.


2.2 In dockerized environment

   . Download flaconi folder
   . Once inside flaconi folder enter the command
         docker-compose -f flaconi.yml up

    . This should create flaconiApiService docker container with the corresponding image

    .Note you may have to install docker engine and docker compose on your test machine

   2.2.1 API TEST

       Setup postman to work in a dockerized environment, please refer the link https://github.com/postmanlabs/newman
  1. View the data

    . Download sqlitebrowser from https://sqlitebrowser.org . Once installed open it and click on Open Database . Proide the path i.e. flaconi-svc/data/flaconi-api.sqlite . Database would be loaded and you can see the tables with relevant entries if any

4. General Points

.The tables in ORM is defined under models folder i.e. category.js

. Routes with core functionality are defined under routes/category folder. 

. logs folder holds the error logs for the day

. db.js sets the link between sequelize and sqlite

. server.js sets up the app locally & sync the database

. all the routes urls could be found in init/initRoutes.js folder                         

categoriesrestapi's People

Contributors

akash123srm avatar

Watchers

 avatar

Forkers

engerim

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.