@mhmurad/respa-back
v1.0.5
Published
A package to create a React back-end project structure
Downloads
351
Maintainers
Readme
React-Structure-Package-Backend
Before you start create this first
:
mkdir name-of-your-project
# follow prompts
cd your-new-project-directory
And then run this
:
npx @mhmurad/respa-back init
Before you run your server do this first
:
// index.js
// please check your own mongodb cluster and embed the only code after @cluster0.yourCode and put it in this uri and also change DB_USER,DB_PASS in .env file
// change the inside bracket() to {}.
const uri = ${`mongodb+srv://$(process.env.DB_USER):$(process.env.DB_PASS)@cluster0.yourCode.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0`};
react-structure-package-backend(respa-back) is a Node.js package that helps you quickly set up a React back-end project structure with essential files and dependencies. By running a single command, you’ll get a boilerplate setup for a React backend app, ready to use with tools like ExpressJS,Cors,jwt,cookie-parser,mongoDB,dotenv and mongoose.
Features
- Automatically creates a standard React project file structure.
- Generates common files like
index.js
,.env
,.gitignore
andvercel.json
. - Installs additional dependencies like
express
,cors
,jwt
,cookie-parser
,dotenv
,mongoDB
andmongoose
. - Saves you time by handling initial project setup and structure creation.
Created Files
index.js
: The entry point for the React backend app..gitignore
: Includes common files and folders to ignore in Git..env
: Includes files to ignore visible for users.vercel.json
: Includes files for deploying on vercel.
Prerequisites
Before using this package, make sure you have:
- Node.js (v14 or later) and npm installed on your system.
Installation
To use react-structure-package-backend(respa-back), you don’t need to install it globally. Instead, use npx
to run it directly:
npx @mhmurad/respa-back init
This command will execute the init.js
script in the package, setting up the project file structure and installing necessary dependencies.
Usage
Run the Initialization Command
To set up the React backend project structure, simply run:
npx @mhmurad/respa-back init
What Happens During Initialization
When you run the command:
A folder structure will be created in your current directory.
Essential files like index.js
and .env
will be generated with starter content.
express
,cors
,jwt
,cookie-parser
,dotenv
,mongoDB
and mongoose
will be installed automatically, appearing in your package.json
as dependencies.
Start Using the Project
Once the structure is created, navigate to your project folder and file (if needed) and install any remaining dependencies (e.g.,enpress
andmongodb
) if they aren't installed by default.
If you have the structure and dependencies already in place, you can just start coding in the index.js
file.
Additional Dependencies
If you need to install additional dependencies, you can add them using npm install
as usual. This package sets up the initial folder structure and installs a couple of common dependencies, but you’re free to add more as needed.
Troubleshooting
Common Issues
Permission Issues
: If you run into permission issues, try using sudo with npx (on macOS or Linux) or run your terminal as Administrator (on Windows).Missing Dependencies
: If express and mongodb are not installed by default, you can install them manually:
npm install express mongodb
Contact
If you run into any issues or have suggestions for improvement, feel free to open an issue on the GitHub repository or contact the maintainer.
License
This package is open-source and available under the ISC License
. See the LICENSE file for more details.