GithubHelp home page GithubHelp logo

fronix / starter-pack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jch254/starter-pack

0.0 1.0 0.0 1.73 MB

Combines React (ft. hooks), Redux, Redux-saga and TypeScript with Auth0 as a starting point for modern web apps with solid authentication

Home Page: https://starter-pack-typescript.603.nz

License: MIT License

Shell 2.08% HCL 7.75% CSS 1.41% HTML 1.41% TypeScript 84.06% Smarty 1.35% Dockerfile 0.68% JavaScript 1.26%

starter-pack's Introduction

Build Status

Overview

Starter Pack combines React (ft. hooks), Redux and Redux-saga with Auth0's Universal Login as a starting point for modern web apps with solid authentication. Why reinvent the wheel? The app utilises Rebass to keep things looking decent. I built this as a way to quickly prototype new ideas.

Webpack (ft. various loaders/plugins/tools) is used to run a local development server and build the production version. Code splitting (with long-term caching in the production version) has been set up via Webpack and React. Webpack's SplitChunksPlugin is used to split vendor code. React.lazy is used for async component-centric code splitting and loading - see App.tsx as an example of creating a split point (restart the dev server if the new chunk is not emitted). MiniCssExtractPlugin is used to split CSS. HtmlWebpackPlugin is used to generate an index.html with the appropriate output assets injected, the Webpack manifest is inlined into index.html to save requests.

The app contains a 'locked down' Books page which requires a user to log in/sign up before content will be visible. The data is read from a local JSON file as this is a only demonstration/starting point. In the real world data would be fetched from an API - see apiService.ts. Protected routes in the API should check validity of the JWT token and return unauthorised if invalid. The app should then prompt the user to log in again. See Serverless API for a more detailed example of authentication in action.

This branch utilises TypeScript for type checking and transpliation to browser-friendly ES5 JavaScript while the master branch is a JavaScript implementation. ESLint (ft. plugins) is run on compilation and will fail the build if errors are reported. Eslint-plugin-css-modules provides type checking of CSS modules - identifying CSS files with unused classes and components using undefined CSS classes e.g. styles.doesNotExist.

Main

Modal

Recommended

Tools Used

AUTH0_CLIENT_ID and AUTH0_DOMAIN environment variable must be set before yarn run commands below.

E.g. AUTH0_CLIENT_ID=YOUR_CLIENT_ID AUTH0_DOMAIN=YOUR_DOMAIN yarn run dev

Running locally (with hot reloading)

  1. Sign up and create a new Auth0 app
  2. Add http://localhost:3001 as an Allowed Origin (CORS) for your newly created app (don't forget to press save)
  3. Run the following commands in the app's root directory then open http://localhost:3001
yarn install
yarn run dev

Building the production version

  1. Run the following commands in the app's root directory then check the /dist folder
yarn install
yarn run build

Running production version locally

  1. Run the following commands in the app's root directory then open http://localhost:3001
yarn install
yarn run prod

Running in Docker container

  1. Run the following commands in the app's root directory then submit requests to http://localhost:3001.
docker build -t starter-pack .
docker run -p 3001:3001 -e AUTH0_CLIENT_ID=YOUR_CLIENT_ID -e AUTH0_DOMAIN=YOUR_DOMAIN starter-pack SCRIPT_NAME

The SCRIPT_NAME value must be one of the npm script names in package.json - e.g. dev or prod. Omitting the SCRIPT_NAME variable will cause the container to exit with a 'No command specified' error and list the available commands.

Deployment/Infrastructure

Refer to the /infrastructure directory.

starter-pack's People

Contributors

dependabot[bot] avatar jch254 avatar szhigunov 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.