Coder Social home page Coder Social logo

random-user-api's Introduction

Express.js CRUD API Documentation

This documentation provides an overview of the endpoints and functionalities of a CRUD API built with Express.js and the File System module. This API performs CRUD (Create, Read, Update, Delete) operations on a .json file that stores user data.

Live Link

https://wild-red-snapper-kit.cyclic.app

Endpoints

Get a random user

GET /users/random Returns a randomly selected user from the .json file.

Get all users

GET /users/all Returns all users from the .json file.

Optional Parameters limit: Limits the number of users returned. For example, /users/all?limit=5 would return the first 5 users. Save a user

POST /users/save

Saves a new user to the .json file. The request body must include the following properties:

  • id (string)
  • gender (string)
  • name (string)
  • contact (string)
  • address (string)
  • photoUrl (string)

Get one user

GET /users/one/:id Returns a user with a specific id from the .json file.

Update one user

PATCH /users/update/:id Updates a user with a specific id in the .json file. The request body must include the properties to be updated.

Bulk update users

PATCH /users/bulk-update Updates multiple users in the .json file. The request body must include an array of ids and the properties to be updated.

Delete one user

DELETE /users/delete/:id Deletes a user with a specific id from the .json file.

Bonus Features

  1. Optional parameters for the GET /users/all endpoint that allow the number of returned users to be limited.
  2. Validation of request bodies for the POST /users/save, PATCH /users/update, and PATCH /users/bulk-update endpoints to ensure that all required properties are present.
  3. Validation of id parameters in the GET /users/one/:id, PATCH /users/update/:id, and DELETE /users/delete/:id endpoints to ensure that the id exists in the .json file.

Conclusion This API provides basic CRUD functionalities on a .json file for user data. The optional parameters, request body validation, and id validation add extra layers of functionality and security.

random-user-api's People

Contributors

rafathbin avatar rafath-auvee 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.