Skip to content

Latest commit

Β 

History

History
155 lines (123 loc) Β· 4.54 KB

File metadata and controls

155 lines (123 loc) Β· 4.54 KB

🌐 NodeJS API

Welcome to the NodeJS API repository!

πŸ“‹ Prerequisites

  • VPS or dedicated Server
  • MySQL Server
  • NodeJS
  • NPM

βš™οΈ Installation

git clone https://github.com/DeadGolden0/NodeJS-API.git
cd NodeJS-API
npm install

πŸ“‹ Configuration

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.

πŸ–₯️ Usage

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.

🀝 Contributing

Your contributions make the open source community a fantastic place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

βœ‰οΈ Contact

For any questions or suggestions, please feel free to contact me:

Discord Gmail Steam

πŸ’– Support 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.

PayPal