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

express-node-starter

v1.11.0

Published

Express, MongoDB, Firebase, and Swagger for API documentation starter for building RESTful APIs

Downloads

39

Readme

Express Node Starter: Empowering Your API Development Journey

Author GitHub license Downloads

REST API Developed with Node.js, Express, MongoDB

Overview

This project provides a robust API skeleton written in JavaScript ES6, suitable for any project. It offers features such as authentication, authorization, JWT tokens, role management, CRUD operations, email notifications, and more. Additionally, it automates the generation of CRUD (Create, Read, Update, Delete) operations for entities within a MongoDB database, streamlining the development process for Node.js applications built on top of Express.js.

Table of Contents

Getting started

This is a basic API skeleton written in JavaScript ES6.

This project will run on NodeJs using MongoDB as database.

API Documentation [Swagger]

Features

  • Authentication and Authorization
  • JWT Tokens, make requests with a token after login with Authorization header with value Bearer yourToken where yourToken will be returned in the Login response.
  • Role Manage
  • Update Profile/Password User Account
  • Reset Password Mail using nodemailer
  • Pre-defined response structures with proper status codes.
  • Included CORS.
  • System notification with Firebase
  • Email Template and settings
  • Validations added.
  • Included API collection for Postman.
  • Light-weight project.
  • Linting with Eslint. (Airbnb style)
  • Included CLI for generating CRUD operations.
  • husky for pre-commit hooks and lint-staged for running linters on git staged files.

Software Requirements

  • Node.js 16+
  • MongoDB 4+

Engines

  • node >=14.16.0 <=20.11.0
  • npm >=6.14.11 <=10.2.4

How to install

Using Git (recommended)

  1. Clone the project from github.
git clone https://github.com/fadhlaouir/express-node-starter.git

Using manual download ZIP

  1. Download repository
  2. Uncompress to your desired directory

Install npm dependencies after installing (Git or manual download)

cd express-node-starter
npm install

Setting up environments

  1. You will find a file named .env.example on root directory of project.
  2. Create a new file by copying and pasting the file and then renaming it to just .env
    cp .env.example .env
  3. The file .env is already ignored, so you never commit your credentials.
  4. Change the values of the file to your environment. Helpful comments added to .env.example file to understand the constants.

Project structure

.
├── .husky
│   ├── _
│   │   ├── .gitignore
│   │   └── husky.sh
│   ├── pre-commit
│   └── pre-push
├── cli
│   ├── _
│   │   ├── deleteCrud.js
│   │   ├── generateEmptyCrud.js
│   │   ├── generateMinimalCrud.js
│   │   └── helpers.js
│   ├── index.js
│   └── README.md
├── .commitlintrc.json
├── .editorconfig
├── .env
├── .env.example
├── .eslintignore.json
├── .eslintrc.json
├── .gitignore
├── .prettierignore.json
├── .prettierrc.json
├── CHANGELOG.md
├── LICENSE
├── package.json
├── README.md
└── server.js

How to run

Running API server locally

If you would like to run the API server on your local environment, you can do so by running the following command: Windows OS

npm run develop

Linux OS or Mac OS

npm run develop:mac
Connected to the database:YOUR_DB_CONNECTION_STRING
App is running ...

Press CTRL + C to stop the process.

Note:

YOUR_DEVELOPMENT_DB_CONNECTION_STRING will be your MongoDB connection string for development environment.

YOUR_PRODUCTION_DB_CONNECTION_STRING will be your MongoDB connection string for production environment.

Creating new models

If you need to add more models to the project just create a new file in src/models/ and use them in the controllers.

Creating new routes

If you need to add more routes to the project just create a new file in src/routes/ and import it in src/app to be loaded.

Creating new controllers

If you need to add more controllers to the project just create a new file in src/controllers/ and use them in the routes.

Using the CLI to generate CRUD operations

  1. Navigate to the project directory.
  2. Run the following command:
npm run crud:operation

See the CLI README section for more details on how to use the CLI to generate or delete CRUD operations.

Follow the prompts to select the CRUD type (empty or minimal) and provide the entity name. The tool will generate the necessary files for the CRUD operations based on your selection.

Linting and Formatting

Running Eslint

npm run lint:check

Fixing Eslint errors

npm run lint:fix

Prettier for code formatting

npm run format:fix

You can set custom rules for eslint in .eslintrc.json file, Added at project root.

Bugs or improvements

Every project needs improvements, Feel free to report any bugs or improvements. Pull requests are always welcome.

License

This project is open-sourced software licensed under the MIT License. See the LICENSE file for more information.

Credits

Support

For any inquiries or issues, please contact Support Email.

  • Optimization: Improved readability by reorganizing the content and ensuring consistency in formatting.
  • Documentation Update: Reflects the changes made to the CLI commands for generating and deleting CRUD operations.
  • Bug Fixes: Resolved issues related to the CLI commands and the project structure.
  • Feature Addition: Added support for generating empty and minimal CRUD operations using the CLI.
  • Code Quality: Improved code quality by adding linting and formatting tools.
  • Security: Updated dependencies to address security vulnerabilities.
  • Testing: Added support for running tests using Jest.
  • Performance: Improved performance by optimizing the code and removing unnecessary dependencies.
  • Refactoring: Refactored the code to improve readability and maintainability.
  • Dependency Update: Updated dependencies to their latest versions.
  • Configuration: Updated the configuration files to reflect the changes made to the project structure.