Skip to content

A template server or kit using Nodejs and ExpressJs for faster web development

License

Notifications You must be signed in to change notification settings

iqbalmdkaify/start-nodeKit

Repository files navigation

Project Title

Start Node Kit is a boilerplate codebase for starting a Node.js Express server, providing example pages for a home, about, and contact page. It’s designed for beginners and anyone needing a basic structure for a web server project.

Features

  • Basic Express server setup
  • Example pages: Home, About, Contact
  • Organized file structure with MVC pattern
  • Uses Handlebars (hbs) as the templating engine
  • Easy to extend and customize
  • Development server with live reload

Tech Stack

It's a server side rendering application with integrated server.

Server: Node, Express

Installation

Follow the steps below to get up and running with the Start Node Kit.

1. Fork the Repository

First, fork the repository to your own GitHub account.

  1. Navigate to the Start-nodeKit repository.

  2. Click the "Fork" button at the top right of the page.

  3. Select your GitHub account as the destination for the fork.

2. Clone the Repository

Once you have forked the repository, clone it to your local machine.

git clone https://github.com/iqbalmdkaify/start-nodeKit.git

3. Navigate to the project Repository

cd start-nodeKit

4. Install Node Modules

npm install

This will install all the packages listed in the package.json file.

5. Run the Development Server

npm run dev

The server will start, and you can view the example pages by navigating to http://localhost:3000 in your browser.

Project Structure

start-nodeKit/
├── controllers/       # Contains application logic and route handlers
│   ├── homeController.js   # Example controller for the home page
│   ├── aboutController.js  # Example controller for the about page
│   └── contactController.js # Example controller for the contact page
├── database/          # Database connection and configuration
│   └── config.js          # Database connection configuration and setup
|   └── db.js          # File for setting up the database connection
|   └── schema.js          # Database schemas and models definitions
├── models/            # Contains database schemas and models
│   └── dataModel.js # Example model file
├── public/            # Static files such as images, CSS, and JavaScript
│   ├── styles/        # Directory for CSS files
│   ├── scripts/       # Directory for JavaScript files
│   └── images/        # Directory for image files
├── views/             # View templates (Handlebars files)
│   ├── home.hbs       # Template for the home page
│   ├── about.hbs      # Template for the about page
│   └── contact.hbs    # Template for the contact page
├── .gitignore         # Specifies files and directories to ignore in Git
├── package.json       # Project metadata and dependencies
├── package-lock.json  # Dependency lock file
└── index.js           # Main application file for the server

1. Detailed Structure

  • controllers/: Contains the logic for handling requests and responses. Each file typically corresponds to a specific page or feature.
  • database/: Includes database connection logic and configuration, such as setting up Mongoose for MongoDB.
  • models/: Contains the database schemas and models used in the application.
  • public/: Stores static assets like CSS, JavaScript, and images. These files are served directly to the client.
  • views/: Holds EJS templates for rendering dynamic HTML content.

This structure helps in maintaining a clean separation of concerns, making the application easier to manage and extend.

2. Customization

You can customize the boilerplate to fit your needs by modifying the existing code or adding new routes, views, and static files.

3. Adding a New Page

  1. Create a new route and controller: Add a new file in the controllers directory.
  2. Create a new view: Create a new HBS(handlebars) file in the views/ directory.
  3. Link the route to the controller: Define the new route in index.js and associate it with the controller logic.

4. Working with Handlebars

This project uses Handlebars (hbs) as the templating engine for rendering views. If you are unfamiliar with Handlebars, you can learn more about it here: Handlebars Documentation.

Handlebars allows you to create dynamic templates with features like helpers, partials, and block expressions, which can be very useful for rendering complex views.

Environment Variables

You can set environment variables in the .env file. For example:

PORT=3000

Contributing

Contributions are welcome! Feel free to fork the project and submit a pull request with your changes. Make sure to follow the project's coding style and conventions.

License

This project is licensed under the Apache 2.0 License. See the LICENSE file for more information.

About

A template server or kit using Nodejs and ExpressJs for faster web development

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published