This project is a URL shortener built with Node.js, using Express for the backend and Tailwind CSS for the frontend. The goal is to allow users to shorten long URLs and retrieve them easily.
url-shortener
├── src
│ ├── server.js # Application entry point
│ ├── app.js # Express application configuration
│ ├── routes
│ │ └── urls.js # Routes for URL shortening
│ ├── controllers
│ │ └── urlController.js # Controller to manage URLs
│ ├── services
│ │ └── urlService.js # Business logic for shortening URLs
│ ├── models
│ │ └── urlModel.js # Data model for URLs
│ └── db
│ ├── index.js # Database connection setup
│ └── prisma
│ └── schema.prisma # Database schema
├── public
│ ├── index.html # Main HTML page
│ ├── index.js # Frontend JavaScript for UI interactions
│ └── css
│ └── styles.css # Styles using Tailwind
├── prisma
│ └── migrations # Database migrations
├── .env.example # Example environment variables
├── package.json # Npm configuration
├── tailwind.config.js # Tailwind configuration
├── postcss.config.js # PostCSS configuration
└── README.md # Project documentation
-
Clone the repository:
git clone <URL_DO_REPOSITORIO> cd url-shortener -
Install dependencies:
npm install -
Configure environment variables:
- Rename
.env.exampleto.envand fill in your database credentials.
- Rename
-
Run Prisma migrations:
npx prisma migrate dev -
Start the server:
npm start
- Open the application at
http://localhost:3000. - Enter a long URL in the input field and click "Shorten URL" to receive a shortened link.
- Use the returned shortened link to be redirected to the original URL.