GithubHelp home page GithubHelp logo

example-react-project's Introduction

Attention: this repository is unmaintained and incomplete. It is an example only and not for use anywhere important.

Example Code Test

This project was written for a code test using React and Loopback.

The brief was to create a React-based form with three fields, one of which gets data from the backend to populate it. The project should have an API and basic error checking/testing. There should also be a second page which shows all previous responses entered into the form.

It is a Loopback 4 back end with a create-react-app based front end. Please see the GitHub Issues for the improvements it needs.

Overview

This is a short form which requests details from a user, saves them to a database, and displays all the saved data.

Installation

This application requires:

  • Node v13.11.0 (may work on older versions)
  • npm or yarn
  • MongoDB v4.2 (may work on older versions)

Install dependencies

npm install for both the front end and back end applications.

Usage

  • Ensure MongoDB is running on localhost using the default port.
  • To run the application, npm start from the back end folder and separately from the front end folder.
  • The front end runs on port 3000, and the back end on 3001.

Note: The react application runs in debug/development mode.

Testing

npm test from either the front or back end folder.

Note: Back end testing is currently not present but can be manually tested using the Loopback explorer.

Deleting data

All data can be used by sending DELETE to http://localhost:3000/answers, or the same using the Loopback explorer at http://localhost:3001/explorer/#/AnswerController/AnswerController.deleteAll

Notes

  • The front end is based on create-react-app and should behave exactly as expected.
  • The back end is a Loopback API and follows normal conventions. The explorer can be accessed on http://localhost:3001/explorer/

Troubleshooting

Please email or call me if you have any issues, I have tried it several times and it works on my machine.

Suggestions/Improvements

Please refer to the GitHub Issues section for this project.

example-react-project's People

Contributors

alexowen avatar

Watchers

 avatar

example-react-project's Issues

Improve MongoDB connections

At the moment a new connection is opened per request, this could be improved with pooling/sharing.

Also, lots of code is duplicated.

Use a more structured API

This could be done well using Lambda, or at least a framework to generate both the skeleton and an OpenAPI/Swagger definition.

Pass errors through to the front end/user

At the moment any error will fail silently and the user is not notified. The UX would be significantly improved if the user knew what the error was or which field has failed validation.

Proper JSDoc documentation

The documentation on the code is below what I would want to push to production, but the majority of it is hopefully straightforward enough it documents itself*.

*I know this isn't true.

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.