decent's official boilerplate for web applications.
-
node
/npm
-
yarn
$ git clone https://github.com/decentorganization/decentapp
$ yarn install
To start a development environment:
$ yarn develop
In another tab:
$ yarn develop:webpack
To build a production application:
$ yarn build
To run the production application:
$ yarn start
To stop the production application:
$ yarn stop
To run tests:
$ yarn test
To lint the src/
directory:
$ yarn lint
To execute yarn test
:
$ yarn precommit
To execute yarn test && yarn build
:
$ yarn prepush
The application (found in src/
) contains a few components:
client/
index.jsx
server/
controller.js
index.js
render.jsx
routing.js
shared/
components/
Example.jsx
Footer.jsx
ModalExample.jsx
NavExample.jsx
pages/
Examples.jsx
Home.jsx
NotFound.jsx
utils/
isProduction.js
App.jsx
config.js
routes.js
client/
is a folder for client-side only javascripts.
client/index.jsx
is the root React app container and handles rendering the application. It also
injects some globals into our application.
server/
is a folder for server-side only javascripts.
server/controller.js
exports functions that are meant to be passed to server-side routes. The data
returned by these functions ends up accessible on the client via window.__SERVER_STATE__
. A new
controller function should be made for each route.
server/index.js
bootstraps the Express server for our application.
server/render.jsx
renders our React application and injects some server-side values into it.
server/routing.js
enables server-side rendering and routing for our React application.
shared/
is a folder for isomorphic (client-side and server-side) javascripts.
shared/components/
is a folder to store React components that do not share their own route (i.e.,
they are not an entire page of our application).
shared/components/Example.jsx
is an example of a functional component that displays input data. It
also uses JSS for styling.
shared/components/Footer.jsx
is the application footer.
shared/components/ModalExample.jsx
is an example of a Bootstrap 4 modal.
shared/components/Nav.jsx
is the application navbar.
shared/pages/
is a folder that contains React applications that have their own routes (i.e., they
are an entire page of our application).
shared/pages/Examples.jsx
is an example of a robust component class that extends the
React.Component class. It includes an asynchronous fetch that updates the state of the component
upon completion.
shared/pages/Home.jsx
is the application homepage.
shared/pages/NotFound.jsx
is the page displayed upon a 404 error.
shared/utils/
is a folder that contains any miscellaneous functions to be used around the
application.
shared/utils/isProduction.js
contains a function that returns a boolean true
or false
(based
on whether the application was run via yarn develop
or yarn start
)
shared/App.jsx
is the inner container for our React app. It also handles client-side routing.
shared/config.js
contains constants relevant to the configuration of our application.
shared/routes.js
contains routes to be used as URLs throughout the application.
Made with ❤️ in Cleveland.