Skip to content

Repository files navigation

🌐 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=
VariableDescriptionOptions
STATUSThe status of the environment where the app is running.development, production
DEV_PORTThe port number the app will use in development environment.Any valid port number, e.g., 3000
PROD_PORTThe port number the app will use in production environment.Any valid port number, e.g., 8080
DB_HOSTThe hostname for the database server.Usually localhost or a remote address
DB_USERThe username for database access.e.g., user123
DB_PASSWORDThe password for database access.e.g., pass123!
DB_NAMEThe name of the database to connect to.e.g., mydatabase
DIALECTThe 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:

DiscordGmailSteam

💖 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

About

A Simple NodeJS Web API template

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages