Welcome to the NodeJS API repository!
- VPS or dedicated Server
- MySQL Server
- NodeJS
- NPM
git clone https://github.com/DeadGolden0/NodeJS-API.git
cd NodeJS-API
npm install
Setup and configure the NodeJS Environement (ENV).
Tip
You can run all the command with sudo
if it requires access to restricted files or elevated privileges. Just prepend sudo
to the command.
mv .env.default .env
nano .env
# Global Env Settings
STATUS=
DEV_PORT=
PROD_PORT=
# Database Settings
DB_HOST=
DB_USER=
DB_PASSWORD=
DB_NAME=
DIALECT=
Variable | Description | Options |
---|---|---|
STATUS |
The status of the environment where the app is running. | development , production |
DEV_PORT |
The port number the app will use in development environment. | Any valid port number, e.g., 3000 |
PROD_PORT |
The port number the app will use in production environment. | Any valid port number, e.g., 8080 |
DB_HOST |
The hostname for the database server. | Usually localhost or a remote address |
DB_USER |
The username for database access. | e.g., user123 |
DB_PASSWORD |
The password for database access. | e.g., pass123! |
DB_NAME |
The name of the database to connect to. | e.g., mydatabase |
DIALECT |
The type of database you are connecting to. | e.g., mysql , postgres , sqlite |
Next, you need to configure NGINX/Apache Server for Reverse Proxy
cd /etc/nginx/sites-available/
nano exemple.com
Add new location to your configuration file
location /api {
proxy_pass http://localhost:YourSelectedPort;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
Replace YourSelectedPort
with the port you have previously configured in the .env
file.
node server.js
If everything has been set up correctly, navigate to https://example.com/api
and the message "API is working"
will appear on the page.
Your contributions make the open source community a fantastic place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For any questions or suggestions, please feel free to contact me:
If you find this project helpful and would like to support my work, you can contribute through PayPal. Any support is greatly appreciated and helps me continue developing and maintaining the project.