This is the backend of the ONLY HANDS app, built with Node.js and Express.js. It provides the API endpoints and interacts with the database to handle data operations.
- Clone the repository:
git clone git@github.com:stasiaDiamond/OH-back.git
- Navigate to the backend directory:
cd OH-back
- Install dependencies:
npm install
:
Backend Dependencies:
Express: npm install express Cors: npm install cors Sequelize: npm install sequelize MySQL2: npm install mysql2 Dotenv: npm install dotenv Nodemailer: npm install nodemailer Firebase: npm install firebase
Before running the app, you need to configure the database connection in the configuration file. Open config/database.js
and set the appropriate values for your database:
Locate the config/database.js file in your project directory. Open the database.js file using a text editor or an IDE. Look for an object containing the database configuration options. Set the appropriate values for your database connection. Replace or add the necessary information for properties like username, password, database, host, port, etc. Save the changes to the database.js file.
The backend uses a MySQL database to store data. Make sure you have a running MySQL server and update the database configuration accordingly.
To initilize the database, run the following commands:
- Navigate into the mysql server:
mysql -u root -p
- Run:
source db/schema.sql
thenexit
. - Run migrations and seed:
npx sequelize-cli db:migrate
thennpx sequelize-cli db:seed:all
.
To start the backend server, run the following command: npm start
.
This will start the server on localhost:9000.
The backend provides the following API routes:
/clients
: Handles user operations (GET, POST, PUT, DELETE)./jobs
: Handles job operations (GET, POST, PUT, DELETE)./invoices
: Handles invoice operations (GET, POST, PUT, DELETE).
Refer to the source code in the controllers
directory for more details about each route.
Contributions are welcome! If you find any issues or want to add new features, feel free to open a pull request.
This project is licensed under the MIT License.