A URL-shortener service that makes long, unwieldy URLs more manageable and shareable.
- Quickly generate short, unique links for any URL.
- User authentication and authorization for managing and tracking personal short links.
- Allow users to set expiration dates for shortened URLs, after which they would be automatically deleted.
- Customizable short links (optional, depending on implementation).
- Track click statistics for shortened links.
- Easy integration into your projects.
- Built with NestJS, a powerful Node.js framework for building efficient and scalable server-side applications.
- Leverages Node.js for fast and reliable performance.
- Uses MongoDB as the database for storing URL mappings and click data, providing flexibility and scalability.
- Add support for custom domain names for shortened URLs.
- Explore caching mechanisms for frequently accessed short links to improve performance.
- Protect the service from abuse by implementing rate limiting on API endpoints.
# install
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
This project uses Husky to manage Git hooks, ensuring that your code meets quality standards before committing.
The Husky pre-commit hook is configured to run the following tasks automatically before each commit:
- Code Formatting: Runs
Prettier
to format your code according to the project's style guidelines. - Linting: Runs
ESLint
to catch and fix any potential issues in your TypeScript code.
These tasks are defined in the lint-staged
configuration, which targets files with specific extensions (e.g., .ts
, .scss
, .json
, .md
) within the src
directory and non-node_modules
directories.
If any of these tasks fail, the commit will be aborted, and you'll need to fix the issues before trying to commit again. This ensures that only properly formatted and linted code is committed to the repository.
In addition to the automated checks, you can manually run the following scripts to ensure your code meets the standards:
# Format code
$ npm run format
# Lint code
$ npm run lint
In order to run the project, first the environment variables should be configured by coping content of file .env-template
to a new .env
and edit it
Swagger can be enabled in the .env
file by setting APP_API_IS_SWAGGER_ENABLED=true
.
Once enabled and running in the development environment, you can visit the Swagger UI at: http://localhost:3000/api/swagger/
The API documentation for the URL Shortener service is provided via Swagger. It offers an interactive interface to explore the available endpoints, test their functionality, and view detailed information about the request and response models.