This is a personal practice project for experimenting with Express.js and TypeScript.
Please note that this demo doesn't use a database. Instead, it loads sample data from a JSON file when the server starts. The project includes a model class that performs CRUD operations on this data.
git clone <repository-url>
cd Express.js-TypeScript-Demo
npm install
To start server run this command:
npm run start
- Use your preferred API client (e.g., Postman, curl) to interact with the API.
- Alternatively, you can use the REST Client extension in Visual Studio Code to test the API directly from the provided posts.http file. The rest.http file contains URLs to all endpoints, making it convenient to make requests and test your API.
GET /api/posts
- Get all postsGET /api/posts/:id
- Get a single postPOST /api/posts
- Create a new postPATCH /api/posts/:id
- Update a postDELETE /api/posts/:id
- Delete a post
.
├── data
│ ├── index.ts
│ └── posts.json
├── http
│ ├── monitoring.http
│ └── posts.http
├── package.json
├── package-lock.json
├── README.md
└── src
├── app.ts
├── controllers
│ ├── apiMonitoring.controller.ts
│ ├── index.ts
│ └── posts.controller.ts
├── dtos
│ ├── index.ts
│ └── posts.dto.ts
├── interfaces
│ ├── index.ts
│ ├── jsonResponse.interface.ts
│ └── post.interface.ts
├── models
│ ├── index.ts
│ └── posts.model.ts
├── routes
│ ├── apiMonitoring.routes.ts
│ ├── index.ts
│ └── posts.routes.ts
└── utils
├── enums
│ ├── HttpStatusCode.enum.ts
│ └── index.ts
└── helpers
├── index.ts
└── notImplementedHandler.helper.ts
Enjoy the demo!