Giter VIP home page Giter VIP logo

swagger-to-ts's Introduction

react-node-template

React Node Template is a simple, unopinionated, full stack web app template, with the goal of facilitating quick prototyping and deployment to Heroku or elsewhere.

This template combines a client generated by create-react-app and a server generated by express-generator.

In local dev, the React dev server & Node server are run side by side, with API calls proxied through the React dev server to the Node server. In production, the Node app will serve both the static React production build and the API.

This project can be deployed as is to Heroku; the heroku-postbuild script will generate a production build of the React app and the start script will kick off the Node server.

See it deployed here: https://react-node-temp.herokuapp.com/

Just click the green Use this template button on the GitHub page for this repo to create your own project based off it.

Overview

The goal of this project is a simple, turnkey, full stack web app that can be easily deployed to Heroku with no further configuration. By combining the frontend client and backend server into the same repository, rapid development and prototyping (possibly by a single developer) are prioritized.

In the interest of being bare-bones and unopinionated, React Node Template does NOT include:

  • Routing: React Router is a good option.
  • State management: Redux is most popular, but there are lighter weight solutions that may be better for some projects.
  • Auth: Many options here, but Auth0 is one of the easier implementation paths.
  • Component styling: Material-UI is fairly turnkey way to get started, or Styled Components if you want the flexibility to design everything yourself.

Development

Project Structure

  • src/client contains the React app
  • src/server contains the Node Express.js app
  • package.json in the project root contains scripts to run in dev mode locally, and also to build and run on Heroku

Local Dev Setup

All commands run from project root:

  1. cd src/client && npm install
  2. cd src/server && npm install
  3. Make sure nodemon & concurrently are installed globally
  4. npm run dev

You will now see the output of both the React dev server and the Node server in your shell, running at the same time thanks to concurrently. Enjoy!

Client<->Server Communication

The Node Express.js server is initialized with one router mounted at /api. We've implemented a sample route at /api/users. Edit the src/server/routes/api.js file to add your own routes and server-side logic.

In the React app, you can see in src/client/src/App.js where we're calling /api/users using fetch. App.js is a functional component, so you can see how we're using useEffect to call our API on component mount, and useState to update component state when we receive a response from the API.

Deployment

Heroku

This project can be deployed as is to Heroku. Check out the Heroku deployment guide for more info. Some of the most popular deployment strategies include:

Elsewhere

Deploying to Amazon Web Services, Google Cloud, Microsoft Azure, etc should work similarly. Just make sure to run the heroku-postbuild script, which generates the React production files, before the start entry point is hit. Depending on your use case and hosting infrastructure, it might make sense to Dockerize this template.

swagger-to-ts's People

Contributors

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