Git Product home page Git Product logo

librarycrud's Introduction

@Library API:

=> Structure : -> Packages used : Express, Mongoose, Bcrypt -> Dev Dependencies : Nodemon

>> API Endpoints and file description :

-> Root Folder:
    app.js : root/main file having all the necessary connections
    
    -> routes (dir) :
        1. auth.js : User Registration (with password encryption) and Login

            > Registration (POST) : localhost:5000/api/auth/register

                * In Body:
                    "userId": "",
                    "pass": ""

            > Login (POST) : localhost:5000/api/auth/login

                * In Body:
                    "userId": "",
                    "pass": ""


        2. library.js : CRUD operation routes
        [ NOTE:
            - ONLY REGISTERED USER CAN CREATE, UPDATE OR DELETE THE LIST, WHILE BOOK LIST CAN BE FETCHED WITHOUT ANY VERIFICATION.

            - 'USER_ID' is being passed as a URL Parameter.
            ( for eg. 'localhost:5000/api/library/add-book/user001' )
        ]
        

            > Adding a book to the 'books' collection (POST) :
                ( 'localhost:5000/api/library/add-book/:user' )
                
                * In Body:
                    "id": "",
                    "title": "",
                    "author": "",
                    "summary": ""   // this can be empty


            > Viewing books list or searching a book using certain queries (GET) :

                1. TO FETCH WHOLE LIST:         // it'll fetch ( id, book-name, author )
                ( 'localhost:5000/api/library/view-book' )

                2. TO FETCH AS PER BOOK_ID:     // it'll fetch ( id, book-name, author, summary )
                ( eg. 'localhost:5000/api/library/view-book?bookId=DBN003' )

                *3. TO FETCH AS PER NAME:               // fetch same as #2
                ( eg. 'localhost:5000/api/library/view-book?bookName=harry' )

                *4. TO FETCH AS PER AUTHOR:             // fetch same as #2
                ( eg. 'localhost:5000/api/library/view-book?author=rowling' )

                *5. TO FETCH AS PER NAME & AUTHOR:      // fetch same as #2
                ( eg. 'localhost:5000/api/library/view-book?bookName=animal farm&author=george orwell' )

                (*) means we may add only keywords of the author and/or book name and it'll fetch all the related books.


            > Updating the book information (PUT) :
            ( eg. 'localhost:5000/api/library/update-book/user001?bookId=DBN003' )

                // This URL will verify user001, and book with id DBN003, and whatever is passed in body will be updated in the database.
                    
                    * In Body:      // We can add any one or more of these updated entries in body.
                        "id": "",
                        "title": "",
                        "author": "",
                        "summary": ""


            > Deleting the book record (DELETE) :
            ( eg. 'localhost:5000/api/library/delete-book/user001?bookId=DBN002' )

                // This URL will verify user001, then check if DBN002 exists in 'books' collection, if yes, it'll delete that record and return the deleted entry.
                

    
    -> database (dir) :
        dbConnect.js     : connection to mongoDB
        UserModel.js    : schema for the 'users' collection ( userId, pass )
        LibraryModel.js : schema for the 'books' collection ( bookId, title, author, summary )

    -> controller (dir) :
        userAuth.js : middleware for user verification in 'users' collection.

=> Instructions to deploy in your local machine :

* MAKE SURE YOU HAVE VS CODE, NODEMON AND MONGODB INSTALLED ON YOUR LOCAL MACHINE.

* Clone the repository into the local machine.
    ( 'git clone https://github.com/rigs05/LibraryCRUD.git' )

* Open the repository in VS Code by right-clicking on the folder.

* Open Terminal, and type "npm install" or "yarn install" (All the Packages will be installed).

* Start your MongoDB server (type 'mongod' in terminal).

* Use ("nodemon" or "node app.js" in terminal) to run the localhost (PORT is 5000).

* Use POSTMAN application, put the URL based on above to perform required task.

* DO VERIFY THAT THE METHODS (GET, POST etc.) ARE CORRECT WHEN MAKING URL REQUEST.

librarycrud's People

Contributors

rigs05 avatar

Watchers

 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.