Certainly! Below is an example of a README.md
file for your project in English:
This is a simple API for shortening URLs and tracking click metrics.
- Fastify - Fast and efficient web framework for Node.js.
- Prisma - ORM for Node.js and TypeScript.
- ioredis - Redis client for Node.js.
- Node.js
- pnpm
- Docker and Docker Compose (to run Redis and Prisma locally)
git clone https://github.com/yan-pi/short-url-node.git
cd short-url-node
pnpm install
Create a .env
file at the root of the project with the following variables:
DATABASE_URL="postgresql://user:password@localhost:5432/db_name"
REDIS_URL="redis://localhost:6379"
docker-compose up -d
npx prisma migrate deploy
pnpm run dev
POST /api/links
Body:
{
"code": "code",
"url": "https://www.example.com"
}
Response:
{
"shortLinkId": 1
}
GET /api/links
Response:
[
{
"id": 1,
"code": "code",
"originalUrl": "https://www.example.com",
"createdAt": "2022-04-01T00:00:00.000Z"
}
]
GET /:code
Redirects to the original URL and increments the click metrics.
GET /api/metrics
Response:
[
{
"shortLinkId": 1,
"clicks": 2
}
]
Connections to Prisma and Redis are automatically closed when the application is shut down.
Feel free to contribute with improvements, bug fixes, or new features!
Feel free to customize and expand the README.md
as needed to meet the specifications and details of your project.