Code Monkey home page Code Monkey logo

ratpack-react-boilerplate's Introduction

ratpack-react-boilerplate

Build Status dependencies Status License

An example single page app with the server using Ratpack and the frontend using React. In a development environment the React components can be live edited so that a browser refresh isn't requierd.

It uses create-react-app because who can keep up with all the build configuration required to build javascript these days.

It handles authentication via the Ratpack Pac4j module using JSON Web Tokens (JWT). It has example of using websockets to transfer data from the JVM to the frontend. AuthenticatorService performs the authentication, use the same username/password to login.

Usage

  • ./gradlew npm_install or npm install from the react directory
  • ./gradlew npm_build or npm build from the react directory
  • ./gradlew npm_start or npm start from the react directory
  • ./gradlew run
  • the browser will open using port 3000

Now edit files under react/src. Your changes will appear without reloading the browser like this:

Demo

New node dependencies can be added to react/package.json.

The node server (port 3000) proxies api requests to the Ratpack server. The Ratpack server (port 5050) will serve up the production optimized built javascript/css assets.

Node Libraries

File Structure

.
├── build.gradle
├── ratpack
│   ├── build.gradle                  # gradle file for building server
│   └── src
│       ├── main
│       │   ├── groovy                # java source
│       │   └── resources             
│       └── ratpack
│           ├── Ratpack.groovy        # server handling
│           └── templates
│               └── index.html -> ../../../../react/build/index.html
│                                     # sym-linked, built from node
├── react
│   ├── build.gradle                  # gradle file which builds the js/css
│   ├── index.html                    # index file template
│   ├── package.json                  # add additional node libraries as needed
│   └── src                           # react javascript code
└── settings.gradle                   # for multi-project build

Windows

The /ratpack/src/ratpack/template/index.html should be sym-linked to /react/build/index.html. In order to do that you can use PowerShell to create the link with the following command:

New-Item -ItemType SymbolicLink -Target react\build\index.html -Path ratpack\src\ratpack\templates\index.html

ratpack-react-boilerplate's People

Contributors

gschrader avatar tiny-dancer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ratpack-react-boilerplate's Issues

Couldn't follow symbolic link

I have attempted to get this project running but am stuck on one thing.

index.html
sym-linked, built from node

Thi doesn't seem to work, is there something special I have to do to copy the index file into my Ratpack resources? I am running Ubuntu

I have tried running this command from the root of my project to manually create the symlink.

ln -s react-app/build/index.html site/src/ratpack/templates/index.html

but I get the error below when I run a ./gradlew build or a ./gradlew clean build

Could not list contents of /home/pocockn/dev/football/site/src/ratpack/templates/index.html Couldnt follow symbolic link

Thanks for the awesome project.

Yarn install/build is run in continuous mode

I've been playing around with this project for a while, I've noticed that if I am just editing my Ratpack application and i am running gradle with -t run it will do the yarn install / build even if no files have changed in the React app. This drastically slows down the build time, is there a way to stop this? Possibly a way of telling the react app not to compile If i know i am just developing the Ratpack app?

index.html not being copied across to ratpack resources

I have attempting to get this project running but this bit

index.html

sym-linked, built from node

Doesn't seem to work, is there something I special I have to do to copy the index file into my Ratpack resources? I am running Ubuntu

Thanks for the awesome project.

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.