Skip to content

This is a simple and quick start node server MVC (Model-View-Controller) template built using TypeScript, Express, and Jest for testing.

Notifications You must be signed in to change notification settings

AG-Jimmy/mvc-node-server-template

Repository files navigation

MVC Template

This is a simple MVC template using Express.js, TypeScript, Jest, and two additional pages for handling 404 errors and API documentation.

Features

  • MVC architecture
  • Jest for testing
  • TypeScript for type safety
  • Two additional pages: Not Found Page and API Documentation Page

Available Routes

  • /: Home page
  • /api-docs: API documentation
  • /*: 404 Page Not Found

File Architecture

mvc-template/
│
├── dist/           # Compiled TypeScript files
│
│── controllers/    # Controller files
│── routes/         # Route files
│── config/         # config files
│── views/          # View files
│── models/         # View files
│── public/         # style and assets files
│── Enums/          # unchangeable variables
|
│── app.ts          # Express application
│── server.ts       # Server setup
├── .env            # Environment variables
├── .gitignore      # Git ignore file
├── package.json    # Project details and dependencies
├── tsconfig.json   # TypeScript configuration
└── README.md       # Project documentation

Dependencies

  • Express: Fast, unopinionated, minimalist web framework for Node.js .
  • dotenv: Loads environment variables from a .env file into process.env .
  • cookie-parser: Parse Cookie header and populate req.cookies with an object keyed by the cookie names .
  • cors: CORS (Cross-Origin Resource Sharing) middleware for Express .

Dev Dependencies

  • TypeScript: Typed superset of JavaScript that compiles to plain JavaScript .
  • Jest: JavaScript testing framework .
  • ts-jest: A TypeScript preprocessor with source map support for Jest .
  • nodemon: Utility that monitors for changes and automatically restarts the server .
  • nodemon: Utility that monitors for changes and automatically restarts the server .
  • ts-node: TypeScript execution environment and REPL for node.js, with source map support .
  • supertest: HTTP assertions made easy, with a fluent API for making requests .

Installation

  1. Clone the repository:
git clone https://github.com/AG-Jimmy/mvc-template.git
  1. Install dependencies:
cd mvc-template
npm install
  1. Install dependencies:
cd mvc-template
npm install

Running the Application

To start the application in development mode, run:

npm run dev

Running the Application

  • To start the application in development mode, run:
npm run dev

This will start the server using ts-node and automatically restart the server when changes are detected.

  • To start the application in production mode, run:
npm start

This will build the TypeScript files and start the server using node.

  • This template is configured with Jest for testing. To run tests, use the following command:
npm test

About

This is a simple and quick start node server MVC (Model-View-Controller) template built using TypeScript, Express, and Jest for testing.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published