Coder Social home page Coder Social logo

zuri-nodejs-task-basic-todo's Introduction

Mongo CRUD (Node js Solution)

  • Task Objective : Setting up of mongo DB connection in a Node.Js server as well as performance of CRUD operations

  • Task Description: Create a Node.js server using any framework of choice (optional) and appropriate folder structure (routes, controllers, models, etc.) which will perform the following functions:

  1. Add a Todo task to a Todo collection
  2. Update a particular Todo task
  3. Delete Todo task
  4. Retrieve all Todo tasks (pagination optional)

Each Todo document should contain at least the following fields: _id, title, description, timestamp.

You can use either a local mongoDB instance or a hosted one on any provider of choice.

Push your code to GitHub and submit your accessible GitHub Link.

To Run this repo locally

clone this branch

git clone https://github.com/kralconomoh/simple_Todolist_api.git

run the following command

yarn
yarn start

after running the yarn start command you should see the following in your terminal / shell

[nodemon] starting `node index.js`
Mongodb Connected
Server Listening on port 3000


Interacting with the endpoints

To create a todo/task

send a post request to this api endpoint

    http://localhost:3000/todos/

with a request body like this

    {
        "name": "Go for a walk",
        "description": "Go For a walk with family at the tafawa balewa square",
    }

To fetch a single todo/task

send a get request to this api endpoint

    http://localhost:3000/todos/todo/6235c4b6eafb61d762520936

response payload

    {
    "_id": "6235c4b6eafb61d762520936",
    "name": "task 2",
    "description": "lorem ipsum soms sjahsgas lehg awehd asssbe jdiifk",
    "createdAt": "2022-03-19T11:55:34.557Z",
    "updatedAt": "2022-03-19T11:55:34.557Z",
    "__v": 0
}

To update a todo/task

send a post request to this api endpoint

    http://localhost:3000/todos/6235b6911f74e43c9be32cb9

with a request body like this.

  • Note the id property
    {
        "name": "Go for a walk",
        "description": "Go For a walk with family at the tafawa balewa square"
    }

To delete a todo/task

send a delete request to this api endpoint

    http://localhost:3000/todos/6235c4b6eafb61d762520936

response payload

    { message:'task deleted successfully' }

To fetch all open task

send a get request to this api endpoint

    http://localhost:3000/todos/all

response payload

   [
    {
        "_id": "6235b6611f74e43c9be32cb7",
        "name": "Go for a walk",
        "description": "Go For a walk with family at the tafawa balewa square",
        "done": false,
        "createdAt": "2022-03-19T10:54:25.099Z",
        "updatedAt": "2022-03-19T10:54:25.099Z",
        "__v": 0
    }
]

Thanks for reading, that is all Bye :)

zuri-nodejs-task-basic-todo's People

Contributors

odebisiidowusolomon 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.