Skip to content

Commit 7e8cc41

Browse files
committed
New Read Me Document
1 parent ae5d8f8 commit 7e8cc41

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

readme.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
## Introduction
2+
This project is an Image Optimization Service built using Node.js and Express. It leverages the Sharp library to perform image transformations such as format conversion, resizing, and quality adjustments. The service is designed to efficiently serve optimized images based on client requests, improving load times and reducing bandwidth usage.
3+
4+
## Features
5+
- Dynamic image format conversion (e.g., JPEG, PNG, WebP, AVIF)
6+
- Image resizing capabilities
7+
- Quality adjustment for optimized images
8+
- Caching mechanism to store and retrieve optimized images
9+
- Configurable source directories for image retrieval
10+
11+
## Structure
12+
13+
```diff
14+
cdn.api.pphat.stackdev.cloud/
15+
├── images/ # Static assets (if any)
16+
├── uploads/ # Static assets (if any)
17+
├── src/
18+
│ ├── controllers/ # Main controller handling image requests and processing
19+
│ │ └── images.controller.ts # Image processing logic using Sharp
20+
│ ├── utils/
21+
│ │ ├── config.ts # Configuration utilities for source directories
22+
│ │ ├── files.ts # File handling utilities
23+
│ │ └── image-cache.ts # Caching utilities for optimized images
24+
│ └── app.ts # Express app setup
25+
├── dist/ # Compiled output directory (after build)
26+
├── package.json # Project metadata and dependencies
27+
├── tsconfig.json # TypeScript configuration
28+
├── README.md # Project documentation
29+
└── .gitignore # Git ignore file
30+
```
31+
32+
33+
## Getting Started
34+
35+
### Prerequisites
36+
- Node.js (version 18 or higher)
37+
- npm (Node Package Manager)
38+
39+
### Installation
40+
1. Clone the repository:
41+
42+
```bash
43+
git clone https://github.com/pphatdev/cdn.api.pphat.stackdev.cloud.git
44+
```
45+
46+
2. Navigate to the project directory:
47+
```bash
48+
cd cdn.api.pphat.stackdev.cloud
49+
```
50+
51+
3. Install the dependencies:
52+
```bash
53+
npm install
54+
```
55+
56+
### Configuration
57+
1. Create a configuration file (e.g., `config.json`) in the root directory to specify source directories and other settings.
58+
2. Define the source directories where images are stored.
59+
60+
### Example `config.json`:
61+
```json
62+
{
63+
"port": 3000,
64+
"sourceDirectories": [
65+
"./images",
66+
"./uploads"
67+
]
68+
}
69+
```
70+
71+
### Development
72+
To run the service in development mode with automatic restarts on file changes, use:
73+
```bash
74+
npm run dev
75+
```
76+
77+
### Build
78+
79+
After building the project, the compiled files will be located in the `dist` directory as ES modules.
80+
81+
To build the project, run:
82+
```bash
83+
npm run build
84+
```
85+
86+
### Running the Service
87+
Start the server using the following command:
88+
```bash
89+
npm start
90+
```
91+
92+
93+
94+
The server will start on the configured port (default is 3000). You can access the service at `http://localhost:3000`.

0 commit comments

Comments
 (0)