Code Monkey home page Code Monkey logo

fury-backend-node's Introduction

fury-backend-node

A employee records microservice built using Node.

Requirements

Getting Started

  1. Click on Fork at the top right corner
  2. Clone your forked repository
  3. cd into the cloned folded | cd fury-backend-node
  4. git remote add upstream https://github.com/hngi/fury-backend-node.git
  5. git pull upstream master
  6. Check out to the task branch | git checkout -b <NAME_OF_THE_TASK>

Project setup

  1. Create .env and copy the content of sample.env | cp sample.env .env
  2. Create .env.test and copy the content of sample.env | cp sample.env.test .env.test
  3. Update the DB credentials | N/B Postgres DB
  4. npm install
  5. npm run lint
  6. npm run dev

Creating a pull request

In the terminal, ensuring that you are located in the root of your repo, run these commands:

  1. git add .
  2. git commit -m "<COMMIT MESSAGE>"
  3. git push origin <BRANCH_NAME>
  4. Go to the repository https://github.com/hngi/fury-backend-node

As soon as you get there, you are going to see a green ‘compare and create a pull request’

  1. Click on it, and type your message, click on create pull request.

If you have any more questions, please check out this resource -> https://www.youtube.com/watch?v=HbSjyU2vf6Y

E-R Diagram

fury-backend-node's People

Contributors

courage173 avatar dave-ok avatar ekpono avatar jan-far avatar lihemen avatar pelpuo avatar piouson avatar simply-alliv avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fury-backend-node's Issues

[FEATURE REQUEST]: Implementation Employees Endpoint Task 5

Is your feature request related to a problem? Please describe.
The implementation is required so that users can actually get all employees.

Describe the solution you'd like

  • Create employees route for getting all employees

Describe alternatives you've considered
Not applicable

Additional context
Not applicable

[FEATURE REQUEST]: Swagger API Docs Task 7

Is your feature request related to a problem? Please describe.
Documentation for the second departments endpoint (updating a department) is required.

Describe the solution you'd like

  • Update departments.yaml file with swagger documentation for the second departments endpoint.

Describe alternatives you've considered
Not applicable

Additional context
Not applicable

[BUG]: Windows users' cmd shell not recognising environment variables in npm scripts

Describe the bug
When running npm run dev or npm run start or the other test scripts on a windows terminal. An error is produced because the windows shell doesn't recognised DEBUG=log and other such commands.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'cd path/to/your/local/fury-backend-node repo'
  2. Run on 'npm run dev'
  3. Scroll down to 'the end of the terminal'
  4. See error

Expected behavior
The command should start a local dev server.

Screenshots
MINGW64__c_Users_Allistair_Google Drive_hng-internship_repositories_fury-backend-node 2020_06_11 07_53_43

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Not Applicable
  • Version: 1909 (Build 18363.900)

Smartphone (please complete the following information):
Not applicable

Additional context
Not applicable

[CHORE]: Update README.md file

The current readme has no information regarding the project.
An updated README.md with a title, brief description, relevant information and steps on how to setup the project locally or otherwise and so on.

[FEATURE REQUEST]: Swagger API Docs Task 1

Is your feature request related to a problem? Please describe.
Documentation for the first employees endpoint (creating a new employee) is required.

Describe the solution you'd like

  • Create documentation using swagger and jsDocs.

Describe alternatives you've considered
Not applicable

Additional context
None

[FEATURE REQUEST]: Add Integration tests for API endpoints

Is your feature request related to a problem? Please describe.
Sometimes unit tests past but the API will still fail. This is why it is important to ensure that all the tested units when put together (integrated) still pass.

Describe the solution you'd like

  • Create tests for all endpoints using Dredd or any other integrated tests framework.

Describe alternatives you've considered
If you have any suggestions on this issue please add a comment.

Additional context
For more information, see:

[FEATURE REQUEST]: Swagger API Docs Task 5

Is your feature request related to a problem? Please describe.
Documentation for the fifth employees endpoint (getting all employees) is required.

Describe the solution you'd like

  • Update employees.yaml file with swagger documentation for the fifth employees endpoint.

Describe alternatives you've considered
Not applicable

Additional context
Not applicable

[DOCS]: Create DATABASE_DESIGN.md

Give brief description of what documentation changes were made.
Not applicable.

A documentation file will be needed to store all information gathered by the people working on the Database Design. A few sections will be required:

  • Create a Table of Contents for the sections
  • Create an Overview section (briefly explain the database design
  • Create an Entities section (list all entities, their attributes, and responsibility)
  • Create a Relationships section (explain relationships between entities)
  • Create an E-R Diagram section (add a picture of the diagram)

People working on this issue should coordinate with people working on the Database Design with E-R Diagram issue

[FEATURE REQUEST]: Implementation Employees Endpoint Task 4

Is your feature request related to a problem? Please describe.
The implementation is required so that users can actually get an employee.

Describe the solution you'd like

  • Create employees route for getting an employee

Describe alternatives you've considered
Not applicable

Additional context
Not applicable

[FEATURE REQUEST]: Implementation Employees Endpoint Task 3

Is your feature request related to a problem? Please describe.
The implementation is required so that users can actually delete an employee.

Describe the solution you'd like

  • Create employees route for deleting an employee

Describe alternatives you've considered
Not applicable

Additional context
Not applicable

[FEATURE REQUEST]: Swagger API Docs Task 6

Is your feature request related to a problem? Please describe.
Documentation for the first departments endpoint (creating a new department) is required.

Describe the solution you'd like

  • Create departments.yaml file with swagger documentation for the first departments endpoint.

Describe alternatives you've considered
Not applicable

Additional context
Not applicable

[DOCS]: Create useful labels for backend nodejs track

Give brief description of what documentation changes were made.

Give brief description of what documentation changes were made.

Organisers please create meaningful Labels to help other backend node interns without tasks find one.

See our Fury Project Board.

Examples:

Skills required

  • Nodejs
  • Fortran
  • Psuedocode
  • None
  • etc

Difficulty

  • Novice
  • Beginner
  • Sage
  • God
  • etc

Other areas

  • who
  • what
  • how

[FEATURE REQUEST]: Endpoint Data Validation

Is your feature request related to a problem? Please describe.
To prevent unnecessary calls to the backend, endpoint request data should be validated.

Describe the solution you'd like

  • Create validation rules with Express Validator, Joi, or any other Node API validation middleware.
  • Sanitize parameters and remove all unexpected parameters.
  • Implement data validation (validate data types and format of parameters).
  • Implement database validation (validate that a resource ID sent by the user is in the database).
  • Implement business rules validation (validate that a user can access other people records only if they are an employer or admin)

Describe alternatives you've considered
You can comment if you know of a better solution to this.

Additional context
For more information, see:

[FEATURE REQUEST]: ENDPOINTS LIST

This is the documentation for all the endpoints, the payloads in the request body and the various paths

More will be updated as it’s been build

Language: JavaScript | Node
Database: PostgreSQL

[FEATURE REQUEST]: Endpoint Documentation

Is your feature request related to a problem? Please describe.
To ensure that users can easily use and understand our microservice api, we will need to create an endpoint documentation.

Describe the solution you'd like

  • Create API Blueprint (Markdown)

Describe alternatives you've considered

  • Swagger
  • ReadMe.io

Additional context
For more information see:

[FEATURE REQUEST]: Swagger API Docs Task 9

Is your feature request related to a problem? Please describe.
Documentation for the fourth departments endpoint (getting a department) is required.

Describe the solution you'd like

  • Update departments.yaml file with swagger documentation for the fourth departments endpoint.

Describe alternatives you've considered
Not applicable

Additional context
Not applicable

[FEATURE REQUEST]: Swagger API Docs Task 8

Is your feature request related to a problem? Please describe.
Documentation for the third departments endpoint (deleting a department) is required.

Describe the solution you'd like

  • Update departments.yaml file with swagger documentation for the third departments endpoint.

Describe alternatives you've considered
Not applicable

Additional context
Not applicable

[FEATURE REQUEST]: Breakdown of main tasks into micro tasks

Is your feature request related to a problem? Please describe.

This is a ticket breaking down available tasks into smaller assignable tasks. Please indicate interest in any task you think you can handle. This is not an exhaustive list and as such suggestions and new ideas are welcome.

Any sub-task that has an issue created and assigned will be indicated here with issue number and assignee. More than one person may be assigned to a task. If there aren't enough tasks on ground. The first valid PR that satisfactorily solves an issue will be accepted and merged.

For coding tasks always lint your code and ensure existing tests and new tests are passing otherwise your PR will fail the tests run on CI and your code will not be merged. To Lint your code simply run npm run lint or npm run lint:fix to fix auto-fixable errors.

DB design:

We are keeping the DB design simple. with a few tables. Please remember suggestions are welcome this is not exhaustive. Use reasonable default values for relevant fields. Note: user_id is gotten from decoding auth token

Table: Employees
Fields: employee_id: bigint, first_name varchar, last_name varchar, phone_no varchar, email varchar, hire_date date department_id bigint, address varchar, user_id bigint

Table: Departments
Fields: department_id bigint, department_name varchar, manager_id bigint, user_id bigint

DB Design Tasks:

  • 1. Create an E-R diagram to represent DB above. issue @ekpono issue #22 solved by PR #23
  • 2. Define SQL statement to create table Employees and save in src/api/db/sql/db-create.sql @ekpono issue #26 solved with #25
  • 3. Define SQL statement to create table Departments and save in src/api/db/sql/db-create.sql @ekpono issue #27 solved with #24

API Endpoints

The API endpoints will need validation, tests and documentation aside from implementation

Validation

  • 1. Create a validation middleware using the Joi library @courage173 issue #20 solved by #28
  • 2. Create validation rule for creating a new Employee object in src/api/utils/validationRules.js @courage173 issue #20 solved by #28
  • 3. Create validation rule for updating an existing Employee object in src/api/utils/validationRules.js @courage173 issue #32 solved by #34
  • 4. Create validation rule for creating a new Department object in src/api/utils/validationRules.js @courage173 issue #35 solved by #38
  • 5. Create validation rule for updating exising Department object in src/api/utils/validationRules.js

Implementation

  • req = required; otherwise = optional
  • response format =>{status, data}

Employees endpoint

  • 1. Endpoint for creating a new employee POST /employees.

  • body - firstName(req), lastName(req), phoneNo(req), email(req), departmentId(req), hireDate(req), address, userId(req)

  • params - none

  • response - [201] - {status: success, data: employeeId}, [400] - {status: error, data: errorMessage}

  • 2. Endpoint for updating employee PUT /employees/:employeeId.

  • body - firstName, lastName, phoneNo, email, departmentId, hireDate, address

  • params - employeeId (req)

  • response - [200] - {status: success, data: employeeDetail}, [400] - {status: error, data: errorMessage}

  • 3. Endpoint for deleting employee DELETE /employees/:employeeId.

  • body - none

  • params - employeeId (req)

  • response - [204] - {status: success, data: successMsg}, [400] - {status: error, data: errorMessage}

  • 4. Endpoint for getting an employee GET /employees/:employeeId.

  • body - none

  • params - employeeId (req)

  • response - [200] - {status: success, data: employeeDetail}, [400] - {status: error, data: errorMessage}

  • 5. Endpoint for getting all employees GET /employees.

  • body - none

  • params - employeeId (req)

  • response - [200] - {status: success, data: array of employeeDetail}, [400] - {status: error, data: errorMessage}

Departments Endpoint

  • 1. Endpoint for creating a new department POST /departments.

  • body - departmentName(req), managerId

  • params - none

  • response - [201] - {status: success, data: departmentId}, [400] - {status: error, data: errorMessage}

  • 2. Endpoint for updating departmentPUT /departments/:departmentId.

  • body - departmentName, managerId`

  • params - departmentId (req)

  • response - [200] - {status: success, data: departmentDetail}, [400] - {status: error, data: errorMessage}

  • 3. Endpoint for deleting department DELETE /departments/:department.

  • body - none

  • params - departmentId (req)

  • response - [204] - {status: success, data: successMsg}, [400] - {status: error, data: errorMessage}

  • 4. Endpoint for getting an department GET /departments/:departmentId.

  • body - none

  • params - employeeId (req)

  • response - [200] - {status: success, data: departmentDetail}, [400] - {status: error, data: errorMessage}

  • 5. Endpoint for getting all departments GET /departments.

  • body - none

  • params - departmentId (req)

  • response - [200] - {status: success, data: array of departmentDetail}, [400] - {status: error, data: errorMessage}

Tests (in Jest)

  • 1. Write unit test for validation middleware

  • 2. Write tests for Employees endpoint 1

  • 3. Write tests for Employees endpoint 2

  • 4. Write tests for Employees endpoint 3

  • 5. Write tests for Employees endpoint 4

  • 6. Write tests for Employees endpoint 5

  • 7. Write tests for Departments endpoint 1

  • 8. Write tests for Departments endpoint 2

  • 9. Write tests for Departments endpoint 3

  • 10. Write tests for Departments endpoint 4

  • 11. Write tests for Departments endpoint 5

Swagger API Docs

Please store all .yaml files for each resource in a separately in the jsDocs folder
Swagger JsDoc
Organizing you swagger .yaml files

Documentation

Update README.md in collaboration with docs team. Ensure all relevant details are in README including:

  • 1. ER-Diagram - @simply-alliv issue #65 solved by #66
  • 2. DB structure Diagram *
  • 3. Flowcharts
  • 4. How it works
  • 5. How to run - @simply-alliv issue #65 solved by #66
    etc..
    This is our window to the world this ensures it is packed and also regularly updated as needed

=======================================================================================================================================================================================

Above tasks will each be picked by a team member. Reply underneath this post with section and sub-task number (the checkbox number). Please tag me (@dave-ok) so I will receive a notification. Then create an issue using the feature request template for the task you intend to work on. When you are done, Indicate your name, sub-task chosen and link to issue you generated here (e.g just #16 is fine). If you have not yet gotten a response just reach out to the sub-group leads for nodeJS so that I can edit the task above indicating you have been assigned and the issue number you created.
If you comment indicating interest in a task. Create the issue right away. If after 20 mins you still haven't created an issue, the task becomes free game for anyone else who wants it.
After the task has been assigned to you, finish it promptly and move to another. When you're done signify and also update your comment where you initially added issue number to include your PR number. Don't linger on a task it may be reassigned. You snooze you lose ;)

Note
Please note that tasks are created in smaller chunks to allow everyone participate. Working a small task doesn't mean you are not competent. It just means you are a great team player

Please update your comments instead of adding another to reduce clutter. E.g to pick a task your comment could look like (include your slack username to make it easy to reach you)

after you have created an issue

after you have completed task and created a PR

[FEATURE REQUEST]: Swagger API Docs Task 2

Is your feature request related to a problem? Please describe.
Documentation for the second employees endpoint (updating an employee) is required.

Describe the solution you'd like

  • Update employees.yaml file with swagger documentation for the second employees endpoint.

Describe alternatives you've considered
N/A

Additional context
N/A

[FEATURE REQUEST]: Swagger API Docs Task 3

Is your feature request related to a problem? Please describe.
Documentation for the second employees endpoint (deleting an employee) is required.

Describe the solution you'd like

  • Update employees.yaml file with swagger documentation for the third employees endpoint.

Describe alternatives you've considered
Not applicable

Additional context
Not applicable

[CHORE] - Create app structure and add dependencies

Brief description of tasks and objectives
Scaffold application creating the initial app structure and installing dependencies

Acceptance criteria to qualify for completion

  • 1. Create application directories
  • 2. Install dependencies

[FEATURE REQUEST]:Validation task-3

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

[FEATURE REQUEST]: Implementation Employees Endpoint Task 2

Is your feature request related to a problem? Please describe.
The implementation is required so that users can actually update an employee.

Describe the solution you'd like

  • Create employees route for updating an employee

Describe alternatives you've considered
Not applicable

Additional context
Not applicable

[FEATURE REQUEST]: Database Design with E-R Diagram

Is your feature request related to a problem? Please describe.
Not related to a problem.

Describe the solution you'd like

  • Determine all required entities and their attributes (update DATABASE_DESIGN.md file)
  • Determine relationships between entities (update DATABASE_DESIGN.md file)
  • Create E-R diagram (update DATABASE_DESIGN.md file)

Describe alternatives you've considered
Not applicable

Additional context
ENTITY RELATIONAL (ER) MODEL is a high-level conceptual data model diagram. ER modeling helps you to analyze data requirements systematically to produce a well-designed database.

image

People working on this issue should coordinate with people working on the Create DATABASE_DESIGN.md issue.

For more information, see:

[FEATURE REQUEST]: README Documentation Task 1

Is your feature request related to a problem? Please describe.
The README file requires an E-R diagram to clearly explain the design of our database.

Describe the solution you'd like

  • Create E-R diagram of database design
  • Add to README.md file

Describe alternatives you've considered
Not applicable

Additional context
Not applicable

[FEATURE REQUEST]: Swagger API Docs Task 10

Is your feature request related to a problem? Please describe.
Documentation for the fifth departments endpoint (getting all departments) is required.

Describe the solution you'd like

  • Update departments.yaml file with swagger documentation for the fifth departments endpoint.

Describe alternatives you've considered
Not applicable

Additional context
Not applicable

[FEATURE REQUEST]: Swagger API Docs Task 4

Is your feature request related to a problem? Please describe.
Documentation for the fourth employees endpoint (getting an employee) is required.

Describe the solution you'd like

  • Update employees.yaml file with swagger documentation for the fourth employees endpoint.

Describe alternatives you've considered
Not applicable

Additional context
Not applicable

[FEATURE REQUEST]: Database design

An entity–relationship model diagram document describing the basic data structure models of an employee, basic information, like role in the organization, specialty, etc

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.