A url shortener service built with NestJS. Check out Attourl on Heroku.
I used this project as a way to learn the NestJS framework. While the framework itself is overkill for a simple url shortener service, the project was involved enough to cover most of the framework's core features.
- Modules, Controllers, Providers
- Custom Providers
- Dependency Injection
- Middleware
- Pipes
- Configuration
- Validation Pipes
- Testing (End-to-End and Unit)
- Serve Static
- Mongoose
- TypeScript
- Express
- MongoDB + Mongoose
- Jest + Supertest
- Tailwind CSS
URL: /api/url/shorten
Method: POST
Request
Body:
{ "longUrl": String (required) }
Response
Code: 201 Created
Body:
{
"urlCode": "urlCode",
"longUrl": "user submitted url",
"shortUrl": "attourl.herokuapp.com/urlCode",
"date": "date created"
}
URL: /:code
Method: GET
Parameters:
:code - urlCode returned from /api/url/shorten PUT
Response
Code: 302 Redirect
Redirects browser to retrieved url.
Code: 404 Not Found
Warns that url is not found.