This is a simple MVC template using Express.js, TypeScript, Jest, and two additional pages for handling 404 errors and API documentation.
- MVC architecture
- Jest for testing
- TypeScript for type safety
- Two additional pages: Not Found Page and API Documentation Page
- /: Home page
- /api-docs: API documentation
- /*: 404 Page Not Found
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
- 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 .
- 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 .
- Clone the repository:
git clone https://github.com/AG-Jimmy/mvc-template.git
- Install dependencies:
cd mvc-template
npm install
- Install dependencies:
cd mvc-template
npm install
To start the application in development mode, run:
npm run dev
- 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