npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

create-express-backend-boilerplate

v0.0.4

Published

Express-Backend-Boilerplate

Downloads

1

Readme

Express-Backend-Boilerplate

Hi everyone this is a boilerplate for express nodejs mongodb boilerplate with dependency injection feature

Quick Start

npx create-express-backend-boilerplate <project-name>

Or

npm init express-backend-boilerplate <project-name>

Manual Installation

If you would still prefer to do the installation manually, follow these steps:

Clone the repo:

git clone --depth 1 https://github.com/Th4p4/Express-Backend-Boilerplate
cd Express-Backend-Boilerplate
npx rimraf ./.git

Install the dependencies:

yarn install

Set the environment variables:

cp .env.example .env

# open .env and modify the environment variables (if needed)

Guide to Deploying the Express-Backend-Boilerplate Project with PM2

This guide will walk you through the process of deploying the "Express-Backend-Boilerplate" project to production using PM2, which is recommended for ensuring stability and robustness in a production environment. The backend is built using Node.js, and the recommended version is Node.js 16.17.0. You can use the check_and_run.sh script to check all the requirements and run the backend script using PM2. Additionally, you'll need to configure a reverse proxy server with specific headers for production.

Prerequisites

Before you proceed with the deployment, make sure you have the following prerequisites in place:

  1. Node.js installed (recommended version: 16.17.0)
  2. Yarn package manager installed
  3. PM2 process manager installed
  4. Nginx or another reverse proxy server set up

Deployment Steps

1. Clone the Project

Clone the "Express-Backend-Boilerplate" project repository from GitHub to your production server. You can use Git for this purpose.

https://github.com/Th4p4/Express-Backend-Boilerplate cd Express-Backend-Boilerplate

2. Configure Environment Variables

Create an .env file in the project directory to configure any necessary environment variables for the "Express-Backend-Boilerplate" project. This file can contain settings like the database connection string, API keys, and the port number for your backend. Ensure it includes all the required variables specific to the backend. You can use .env.example as a reference.

3. Check with script and Run with PM2

You can use the provided check_and_run.sh script to check for requirements and run the backend server using PM2. Execute the script: ./check_and_run.sh

Using pm2 you can run the project as: Install dependencies yarn install

Run Project pm2 start yarn --name "Express-Backend-Boilerplate" -- dev

This command tells PM2 to start the yarn dev script and names the process "Express-Backend-Boilerplate" By default this runs in port 5000, but you can configure this to run on other port using .env file.

4. Configure the Reverse Proxy Server (Nginx)

Configure your reverse proxy server (e.g., Nginx) to route requests to your backend server. Here's an example Nginx configuration:

server { listen 80;
server_name your_domain.com;

location / {
    proxy_pass http://127.0.0.1:5000; # This assumes your backend is running on port 5000
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    # CORS headers
    add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PATCH, PUT, DELETE';
    add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization';

    # Additional Nginx configuration settings...
}

}

Make sure to replace your_domain.com with your actual domain and configure the proxy_pass directive to point to the correct backend server URL. The backend have build in functionality to handle CORS therefor CORS is not needed in the config. Contact if any issues

5. Testing and Maintenance

After deployment, thoroughly test the "Express-Backend-Boilerplate" API to ensure it's working as expected in a production environment. Monitor the application for any issues, and regularly update environment variables or the project code as needed.

Congratulations! You've successfully deployed the "Express-Backend-Boilerplate" project to production using PM2. Your backend API is now accessible through the specified domain or IP address, with the necessary CORS headers and reverse proxy configuration in place.