Source: Jolli-sample-repos/url-shortener Last Updated: 4/8/2026
Getting Started
Prerequisites
- Node.js 16+
- npm 7+
- Python 3 (for frontend server)
Installation
# Backend
cd backend && npm install && npm run dev
# Frontend (separate terminal)
cd frontend && python -m http.server 8000Backend: http://localhost:3001 Frontend: http://localhost:8000
Verify backend is running:
curl http://localhost:3001/health
# Returns: {"status":"healthy","timestamp":"2024-01-15T10:00:00.000Z"}Using the Frontend
Open http://localhost:8000 to use the web interface:
- Create URLs with form
- View list of all URLs
- Copy short URLs to clipboard
- Delete URLs
Using the API
Create a short URL:
curl -X POST http://localhost:3001/api/v1/urls \
-H "Content-Type: application/json" \
-d '{"longUrl": "https://example.com"}'
# Returns:
# {
# "shortCode": "AbC123",
# "longUrl": "https://example.com",
# "createdAt": "2024-01-15T10:00:00.000Z",
# "clicks": 0
# }Access the short URL (use shortCode from response):
curl -L http://localhost:3001/r/AbC123
# Redirects (302) to https://example.comView full API Reference for all endpoints.
Configuration
Optional .env in backend/:
PORT=3001
BASE_URL=http://localhost:3001
NODE_ENV=developmentTroubleshooting
Port in use: Change the port in use, you may want to consider using .env file if you come across this issue.
PORT=3002 npm run devModule not found: Typically when there are missing dependencies, node module corruption, or commands run in the wrong directory.
cd backend
rm -rf node_modules package-lock.json
npm installTypeScript errors: Typically for incompatible Node.js version, malformed tsconfig.json, or using the wrong npm command (npm start for example).
npm run build # Check compilation errors