Boilerplate Overview: NodeJS + React
Boilerplate is a pre-written codebase that speeds up development by providing a foundational template for building extensions.
Prerequisite
If you do not have the boilerplate, please go through the steps in the Get Started page.
Alternatively, if you have already setup FDK CLI, run the fdk ext init --template node-react
command to dowload the boilerplate explained in this page.
Directory Structure
├── README.md
├── .env # Environment variables
├── extension.context.json # DO NOT TOUCH. Managed FDK CLI
├── index.js # Entry file for the backend
├── server.js # Main server file for the backend
├── frontend # Frontend
│ ├── README.md
│ ├── index.html # Entry point for the frontend
│ ├── index.jsx
│ ├── router.jsx # React Router configuration
│ ├── App.jsx
│ ├── pages
│ │ ├── Home.jsx # Home page component
│ │ ├── NotFound.jsx
│ │ └── style/ # Page styles
│ ├── test/ # Frontend tests
│ └── package.json
├── test/ # Backend tests
└── package.json
Backend
We use the JavaScript Extension Helper Library to handle authentication, use SDKs methods for APIs, and subscribe to webhooks.
Dependencies
@gofynd/fdk-extension-javascript
for interacting with Fynd Commerce.@gofynd/fdk-client-javascript
a peer dependency for the previous library.express
for running our server.sqlite3
for session storage.- Middlewares like
dotenv
andserve-static
- Development dependencies like
nodemon
,jest
, andsupertest