Skip to content

rasif-sahl/express-simplicity

Repository files navigation

Express Simplicity: Default Folder Structure And Essential Packages For Express.js

Jumpstart your Express.js and Node.js projects with the Express.js Starter Kit. This npm package provides a default folder structure and installs essential npm packages to help you quickly set up and build robust web applications.

👉 Key Features

  • Organized Folder Structure: The Express.js Starter Kit creates a predefined folder structure with neatly organized directories for routes, controllers, models, views, and public assets.
  • Pre-configured Express.js Server: Get started right away with a basic Express.js server that comes pre-configured with routing and error handling.
  • Essential NPM Packages: Save time and effort by having commonly used npm packages for Express.js, such as nodemon, express, and dotenv, automatically installed. These packages enhance security and streamline your development process.
  • Best Practices and Sample Code: The Starter Kit includes sample code and configuration files that follow best practices, allowing you to start building your application immediately.

👉 Requirements

  • Node js should be installed.
  • npm or yarn should be installed.

👉 Installation

To get started,

  • Install the Express Simplicity Starter Kit globally using npm:
npm install -g express-simplicity
  • Then open your terminal and navigate to your folder where you wont to install the template
cd < path to the project directory >
  • After navigating to the folder run this command it will generate the files and install the dependencies.
express-simplicity
  • After generating the files run this command to start the server.
npm run express
  • Move on to your preferred browser and paste this URL.
http://localhost:3000/

👉 Packages

  • dotenv: Loads environment variables from a .env file into process.env.
  • nodemon: Automatically restarts the Node.js application when changes are detected in the source code.
  • express: A web framework for Node.js that simplifies the process of building web applications. you can access the api routes similarly.
  • mysql: The MySQL Node package: Simplifying MySQL database interactions in Node.js.

👉 Additional Comments

  • Change the env-example.txt file to .env to enable the usage of environment variables in your project.
  • I have added some boilerplate code in the controllers, models and routes folder. I have use the MVC architecture in this.
http://localhost:3000/api/users
http://localhost:3000/api/users/5
  • To connect this application to the database you can replace these .env variables with your db credentials.
DB_HOST=
DB_USERNAME=
DB_PASSWORD=""
DB_NAME=

# If you are getting any unexpected errors you can add the socket path to
SOCKET_PATH=
  • I have added comments on the userModels files and the userController file on how to get data from the database once the db is connected.

👉 License

The Express.js Starter Kit is licensed under the ISC License.