This repository contains the backend and frontend setup for a web application, with the backend built using Express.js and the frontend using React.js.
- Clone Repository:
git clone https://github.com/slametaji-ui/RestFullAPIAuthJWT.git
- Navigate to Backend Directory:
cd backend
- Install Dependencies:
npm install
- Set Up Environment Variables:
- Create a
.env
file based on the.env.example
provided.
PORT=5000
DB_DIALECT=mysql
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=
DB_DATABASE=db_auth
ACCESS_TOKEN_SECRET = alksjalkjdna92iaje9asdsajdklajsk3j9ewr0dsakljdklsaadua905inklds
REFRESH_TOKEN_SECRET = alksjalkjdnapoalhriikeub92iaje93j9ewr0dsakljdklkjoli54n6lk4dua
- Configure the required environment variables such as database connection details, API ACCESS_TOKEN_SECRET and REFRESH_TOKEN_SECRET.
- Run Development Server:
npm start
This command will start the Express.js server.
- Testing:
- Utilize tools like Postman or curl to test your endpoints.
- The default base URL would be
http://localhost:5000
.
- Deployment:
- Configure your preferred deployment method (e.g., Heroku, AWS, etc.).
- Ensure all environment variables are set correctly in the production environment.
- Navigate to Frontend Directory:
cd frontend
- Install Dependencies:
npm install
- Run Development Server:
npm start
This command will start the React development server.
- Testing:
- Access your application in a web browser at
http://localhost:3000
. - Test all features and components to ensure proper functionality.
- Deployment:
- To deploy your React application, build it first using:
npm run build
- This will create an optimized production build in the
build
directory. - Deploy the contents of the
build
directory to your chosen hosting service (e.g., Netlify, Vercel, AWS S3, etc.).
- Ensure both backend and frontend are configured to communicate properly, considering CORS policies.
- Follow best practices for security, error handling, and documentation.
- Keep dependencies updated regularly to maintain security and stability.