This is a modern TypeScript-based Node.js application built with Express framework, implementing the MVCS (Model-View-Controller-Service) architecture pattern with Pug templating engine. The application demonstrates server-side rendering, RESTful API endpoints, data management, and TypeScript integration.
- TypeScript implementation for type safety and better developer experience
- MVCS architectural pattern for clear separation of concerns
- Server-side rendering with Pug templates
- RESTful API for product management
- Fake data generation using @faker-js/faker
- Static file serving
- Error handling with custom 404 page
-
Clone the repository:
git clone <repository-url>
-
Navigate to the project directory:
cd nodejs-MVCS+PUG
-
Install dependencies:
npm install
To start the application in development mode with hot-reloading:
npm run dev
To build the TypeScript code:
npm run build
To start the application in production mode:
npm start
Access the application at: http://localhost:5050
GET /
- Home page with welcome messageGET /products
- View all productsGET /products/:id
- View details of a specific product
GET /api/products
- Get all productsGET /api/products/:id
- Get a specific product by IDPOST /api/products
- Create a new productPATCH /api/products/:id
- Update a productDELETE /api/products/:id
- Delete a product
server.ts
- Main application entry pointcontrollers/
- Business logic for handling requestsinterfaces/
- TypeScript interfaces for type definitionsmodels/
- Data modelsservices/
- Service layer implementationutils/
- Utility functions including fake data generationpublic/
- Static files (CSS, JS, images)views/
- Pug template files
- Language: TypeScript
- Runtime: Node.js
- Framework: Express.js
- Template Engine: Pug
- Data Mocking: @faker-js/faker
- Development Tools: Nodemon, ts-node
- Express.js - Web application framework
- Pug - Template engine for server-side rendering
- TypeScript - JavaScript with syntax for types
- Nodemon - Utility for automatic server restart during development
- ts-node - TypeScript execution engine for Node.js
- @faker-js/faker - Generating fake data
- @types/express, @types/node - TypeScript type definitions
MIT