This project is a simple service that allows users to get shorter versions of urls.
- Programming language: Typescript
- Environment: Node
- Server framework: Express
- Database: PostgreSQL
- ORM: TypeORM
- Test: Vitest
- Lint: Eslint
- Code formatter: Prettier
- Logger: Winston
- .eslintrc: Eslint configuration file
- .prettierrc: Prettier Formatt configuration file
- vitest.config.ts: Vitest configuration file
src/app/
: ORM config and Express Server entry pointsrc/url/
: Urldelivery/
: Express routes and middlewaresdomain/
: Domain of the entity, repository and usecase interfacesrepository/
: ORM Schema and requestsusecase/
: Business rules
test/
: Tests
- Create
.env
file from.env.example
, filling in the missing details - Install dependencies:
npm install
- Build server:
npm run build
- Start server:
npm run start
- Create and run containers:
docker-compose up --build
- Verify docker containers logs:
docker-compose logs -f
- Stop and remove containers:
docker-compose down
- Shorten an URL
POST /api/url
Request body
{
originalUrl: string,
alias: string?
}
Response
{
"message": string
"shortUrl": string | null
}
- Redirect shortened URL
GET /api/url/:urlCode
Source: https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html