Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rasif-sahl/express-simplicity

Express Simplicity: Default Folder Structure and Essential Packages For Express.js
https://github.com/rasif-sahl/express-simplicity

backend boilerplate code-generation code-generator crud express expressjs javascript javascript-library mvc mvc-architecture node-js nodejs routing starter-kit web-development

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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.



## :point_right: 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.

## :point_right: Requirements
* `Node js` should be installed.
* `npm` or `yarn` should be installed.
## :point_right: Installation

To get started,

* Install the Express Simplicity Starter Kit globally using npm:

```bash
npm install -g express-simplicity
```

* Then open your terminal and navigate to your folder where you wont to install the template

```bash
cd < path to the project directory >
```

* After navigating to the folder run this command it will generate the files and install the dependencies.

```bash
express-simplicity
```

* After generating the files run this command to start the server.

```bash
npm run express
```

* Move on to your preferred browser and paste this URL.

```bash
http://localhost:3000/
```

## :point_right: 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.

## :point_right: 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.

```bash
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.

```bash
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.

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