A universal react app with SSR and database support
git clone git@github.com:dhruv-m-patel/universal-react.git
nvm use
corepack enable
yarn set version self
yarn install
yarn start-dev- Edit
config/config.jsonto setup default configuration for including the middleware to intercept request or app startup - To add environment-specific overrides, edit
config/production.json,config/development.json,config/staging.jsonorconfig/test.json
- Add your middleware in
src/server/middleware(Reference:renderPagemiddleware) - Add configuration for loading middleware with an appropriate order in
config/config.json(Reference:renderPagemiddleware configuration entry)
- Add environment variables in
.envfile referring to.env.examplerequired for database connection - Set
DB_DRIVER=mysqlwith your database credentials - Make sure the environment variables are loaded
- Make sure to refer to
src/lib/clients/mysql.jsand useexecuteQueryto run your database queries in the application. You can directly access database with request object usingreq.app.db. - Run the app
- Add environment variables in
.envfile referring to.env.examplerequired for database connection - Set
DB_DRIVER=pgwith your database credentials - Make sure the environment variables are loaded
- Make sure to refer to
src/lib/clients/postgres.jsand useexecuteQueryto run your database queries in the application. You can directly access database with request object usingreq.app.db. - Run the app
- Run
yarn migration:createto create a new migration - Run
yarn migration:applyto apply migration to local database - Run
yarn migration:apply:stageto apply migration to staging database - Run
yarn migration:apply:prodto apply migration to production database - Run
yarn migration:undoto undo a previously ran migration, one at a time.
- React v18
- Webpack v4
- Babel v7
- Express v4
- Storybook
- Jest
- ESLint
- StyleLint
Uses Husky to run linter on every commit, runs test before pushing commits
Supports Configuration (using confit / meddleware), Code splitting (using loadable components), React Bootstrap (For bootstrap style react components)