A REST API built with Node.js and TypeScript to generate a shorter url of a logn url.
- Node.js >= 20
- Clone the repository:
git clone <repository-url>
cd url-shortener-backend
- Install dependencies:
npm install
- Configure environment variables:
cp .env.example .env
- Update .env with your credentials
DATABASE_URL=postgres://<postgres-username>:<postgres-password>@localhost:5432/shortener
PORT=8000
HOST=http://localhost:8000
- Testing the application
npm run test
- Seed the database:
npm run db:seed
- Start the development server:
npm run dev
The api server will run at http://localhost:8000
GET /api/shorteners
- List all the urlsPOST /api/shorteners
- Generate a new short urlDELETE /api/shorteners/:id
- Delete a urlGET /api/:short_url
- Redirect to full url