npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cra-template-build-week-template

v1.4.2

Published

React boilerplate for Lambda Build Week projects

Downloads

6

Readme

A create-react-app template designed for Lambda School Build Week projects.

npx create-react-app PROJECT-NAME --template cra-template-build-week-template

Lambda School Build Week Boilerplate -- create-react-app with redux

This is a create-react-app boilerplate for build week projects at Lambda School.

This particular template comes with redux already set up. The store and Provider have been set up in App.js, with redux-thunk being used as some middleware to help with handling asynchronous activity like API calls. Some very basic file structures have been set up for the reducers and actions to help get you started.

In the utils folder, an axiosWithAuth file has been created, with some basic structure set up for the headers and baseURL for axios. It also utilizes localStorage to store an authorization token. This token can be received from a server via a POST request when the correct credentials are provided in the body of the request. Then in your components, wherever you need to use axios that requires authorization, import axiosWithAuth and invoke the function in place of where you would put axios. Change or even delete the file as needed.

import { axiosWithAuth } from "../utils/axiosWithAuth";

...

axiosWithAuth()
  .post("/login", user)
  .then(res => {
      localStorage.setItem("token", res.data.payload);
      props.history.push("/URL PATH YOU WANT TO LOGIN TO HERE");
  })
  .catch(err => {
      localStorage.removeItem("token");
      console.log("Invalid login: ", err);
  });

In the components folder, a PrivateRoute component has been created. When you use this component, the syntax is the same as a normal Route component where you provide the path and the component to be rendered. The PrivateRoute checks to see if you have stored a token in localStorage. This assumes that you are also using the provided axiosWithAuth that receives a token and stores it in localStorage.

Formik and Yup have also been added as dependencies for your convenience to use for creating your forms and adding form validation. Styled-components have been included as well. It is a common styling tool for Build Week projects at Lambda School since it is more widely known by students.

This template also comes with dependencies like prettier, eslint, husky, and lint-staged to make the team collaboration smoother by helping to keep code structure consistent and help prevent some poor code from being committed and pushed into production. Unfortunately, create-react-app doesn’t support devDependencies, so you have to manually put them as devDependencies after your project is bootstrapped.

Specifically, Kent C. Dodd's eslint config has been used with this template. To customize any of the rules, edit the .eslintrc file to override Kent's rules.

A default formatting for prettier has been provided. To make changes, edit the .prettierrc file.

You can add the following to your package.json in your project directory to customize your husky and lint-staged dependencies:

"husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
"lint-staged": {
    "*.js": [
        "eslint"
    ],
    "*.+(js|jsx|json|yml|yaml|css|less|scss|ts|tsx|md|graphql|mdx)": [
        "prettier --write",
        "jest --findRelatedTests",
        "git add"
    ]
}

With this setup, when you run a git commit command, husky runs lint-staged. In our lint-staged, we've told it to run our eslint rules on all .js files. Then run prettier on all of the listed file types to make sure they're all consistently formatted. Then run all of our tests that are related to the files being committed with jest. Finally, if a file is changed, due to formatting from prettier or something else in this process, we do git add again to make sure that those changes are staged and ready to be committed. If these scripts pass, then all of the files will actually be committed.