starter-kit
starter-kit copied to clipboard
Starter kit for full-stack JavaScript projects
Starter Kit
- [x] Full stack ES8+ with Babel
- [x] Node LTS support (verified working on 18.x and 20.x LTS releases)
- [x] Express server
- [x] Logging with Winston and Morgan
- [x] React client with Webpack
- [x] Client-side routing with React Router
- [x] Linting with ESLint
- [x] Unit and integration testing with Jest (and SuperTest)
- [x] E2E testing with Cypress
- [x] Dev mode (watch modes for client and server, proxy to avoid CORS issues)
- [x] Production build (single deployment artifact, React loaded via CDN)
- [x] GitHub Actions pipeline
- [x] Heroku or Render deployment
- [x] Cloud Foundry deployment
- [x] Docker build
Scripts
Various scripts are provided in the package file, but many are helpers for other scripts; here are the ones you'll commonly use:
dev: starts the frontend and backend in dev mode, with file watching (note that the backend runs on port 3100, and the frontend is proxied to it).e2e: builds and starts the app in production mode and runs the Cypress tests against it.e2e:dev: builds and starts the app in dev mode and runs the Cypress tests against it.e2e:local: opens Cypress on the desktop, instead of running it in the background. Doesn't start the app.lint: runs ESLint against all the JavaScript in the project.serve: builds and starts the app in production mode locally.ship: runslint, thentest, thene2e; ideal before agit push.test: runs the Jest unit and integration tests.test:cover: runs the tests and outputs coverage data.test:watch: runs the unit and integration tests in watch mode.
Debugging
While running the dev mode using npm run dev, you can attach the Node debugger to the server process via port 9229.
If you're using VS Code, a debugging configuration is provided for this.
There is also a VS Code debugging configuration for the Chrome debugger, which requires the recommended Chrome extension, for debugging the client application.
Troubleshooting
See the guidance in the wiki.
Rationale
Partly I wrote this to explore what things like Create React App (CRA) are doing under the hood with Babel and
Webpack. Partly it was to simplify a previous starter kit, so there aren't multiple package entry points complicating
the automation and it's not using copy (which caused cross-platform issues on Windows).
Pros
- A single root ESLint configuration keeps the project's code consistent to minimise context switching
- Having Jest running once for the whole project means you can run
test:watchand see the tests related to changes anywhere in the codebase - Less hidden "magic" config than when using CRA
- Simpler orchestration with a single NPM entry point
Cons
- The single
package.jsonis getting a bit unwieldy; there are 20+ scripts and it's unclear what part of the app each dev dependency is for (if you're using NPM 8 you can see one alternative for this using workspaces in Impasse, which was based on this starter kit) - Cypress only runs in Electron/Chrome (for a more cross-browser alternative, see Codecept)
To consider