Coder Social home page Coder Social logo

zohaibrao / employeeapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sagiweizmann/employeeapi

0.0 0.0 0.0 259 KB

๐Ÿ‘ฅ Employee API: A versatile Node.js and Express-based REST API for managing employee data. This API allows you to create, read, update, and delete employee records, making it easy to handle employee information in your organization. Powered by modern web technologies and designed for flexibility and scalability.

License: MIT License

JavaScript 100.00%

employeeapi's Introduction

Employee API README

This README provides documentation for the Employee API, including its controllers and routes.

Swagger Documentation

Preview of the api in Swagger UI

Alt Text

Usage

git clone [email protected]:sagiweizmann/EmployeeAPI.git
cd EmployeeAPI
npm install
cp .env.example .env

Run the server in development mode:

npm run dev

Build the server for production:

npm run build

Start the server in production mode:

npm run start

Run Unit Tests:

npm run test:unit

Run Unit Tests:

npm run test:integration

Table of Contents


Controllers

getEmployee

  • Description: Retrieves a specific employee by their ID.
  • Parameters:
    • req: The request object.
    • res: The response object.
    • next: The next middleware function.
  • Response:
    • HTTP Status Code: 200 OK if successful, 404 Not Found if employee not found.
    • JSON Response:
      • employee: The retrieved employee object.

getAllEmployee

  • Description: Retrieves all employees of a specific recipient.
  • Parameters:
    • req: The request object.
    • res: The response object.
    • next: The next middleware function.
  • Response:
    • HTTP Status Code: 200 OK if successful, 200 OK with an empty array if no employees found.
    • JSON Response:
      • employees: An array of employee objects.

createEmployee

  • Description: Creates a new employee.
  • Parameters:
    • req: The request object containing the employee data.
    • res: The response object.
    • next: The next middleware function.
  • Response:
    • HTTP Status Code: 201 Created if successful.
    • JSON Response:
      • employee: The newly created employee object.

deleteEmployee

  • Description: Deletes an employee by their ID.
  • Parameters:
    • req: The request object.
    • res: The response object.
    • next: The next middleware function.
  • Response:
    • HTTP Status Code: 200 OK if successful, 404 Not Found if employee not found.
    • JSON Response:
      • message: "Employee deleted."

patchEmployee

  • Description: Updates an employee by their ID with the fields provided in the request body.
  • Parameters:
    • req: The request object containing the employee data to update.
    • res: The response object.
    • next: The next middleware function.
  • Response:
    • HTTP Status Code: 200 OK if successful, 404 Not Found if employee not found.
    • JSON Response:
      • employee: The updated employee object.

Routes

Get Employee by ID

  • URL: /v1/employee/:id
  • Method: GET
  • Description: Retrieves a specific employee by their ID.
  • Parameters:
    • id (URL Parameter): Employee ID.
  • Response:
    • HTTP Status Code: 200 OK if successful, 404 Not Found if employee not found.
    • JSON Response:
      • employee: The retrieved employee object.

Get All Employees

  • URL: /v1/employee
  • Method: GET
  • Description: Retrieves all employees of a specific recipient.
  • Parameters:
    • recipient (Query Parameter): Employee recipient.
  • Response:
    • HTTP Status Code: 200 OK if successful, 200 OK with an empty array if no employees found.
    • JSON Response:
      • employees: An array of employee objects.

Create a New Employee

  • URL: /v1/employee
  • Method: POST
  • Description: Creates a new employee.
  • Request Body:
    • recipient: Employee recipient.
    • employee: Employee content.
    • sender: Employee sender.
  • Response:
    • HTTP Status Code: 201 Created if successful.
    • JSON Response:
      • employee: The newly created employee object.

Delete Employee by ID

  • URL: /v1/employee/:id
  • Method: DELETE
  • Description: Deletes an employee by their ID.
  • Parameters:
    • id (URL Parameter): Employee ID.
  • Response:
    • HTTP Status Code: 200 OK if successful, 404 Not Found if employee not found.
    • JSON Response:
      • message: "Employee deleted."

Update Employee by ID

  • URL: /v1/employee/:id
  • Method: PATCH
  • Description: Updates an employee by their ID with the fields provided in the request body.
  • Parameters:
    • id (URL Parameter): Employee ID.
  • Request Body: The fields of the employee to update.
  • Response:
    • HTTP Status Code: 200 OK if successful, 404 Not Found if employee not found.
    • JSON Response:
      • employee: The updated employee object.

This API provides basic CRUD (Create, Read, Update, Delete) operations for managing employee data. Ensure that you have appropriate error handling and validation in place as per your application's requirements.

employeeapi's People

Contributors

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