The project assignment for roadmap.sh
URL of the assignment in roadmap.sh:
https://roadmap.sh/projects/url-shortening-service
This API creates and manages short URLs using a Postgres database (ORM:
Drizzle).
Each short URL consists of a short code and a key to authenticate the creator.
Using the key, creators can edit or delete their short URLs and can also see
their stats.
The API has rate limiting to prevent abuse.
Read the docs here.
-
Clone the repository:
git clone https://github.com/ilia-abbasi/URL-Shortening-Service.git cd URL-Shortening-Service -
Install dependencies:
npm install
-
Create the
.envfile inside the/miscdirectory and set the variables:PORT=your_port DATABASE_URL=your_database_connection_string DATABASE_URL_TEST=your_test_database_connection_string
You can ignore
DATABASE_URL_TESTif you don't want to run tests. -
Create the required tables in your database:
npm run generate # Generate migration files npm run migrate -
If you want to run tests too, create the required tables in your test database:
npm run migrate:test
-
Build the project:
npm run build
-
Run the server with:
npm run start
-
Send requests using Postman. Testing short URLs is better done with a browser.
Testing is done with jest.
-
Run all the tests with:
npm run test -
Run unit tests with:
npm run test:units
-
Run e2e tests with:
npm run test:e2e
- dotenv
- drizzle-orm
- express
- express-rate-limit
- express-validator
- morgan
- pg
- @types/dotenv
- @types/express
- @types/express-rate-limit
- @types/express-validator
- @types/jest
- @types/morgan
- @types/node
- @types/pg
- @types/supertest
- drizzle-kit
- jest
- nodemon
- supertest
- ts-jest
- tsx
- typescript
The source code is formatted with Prettier.
URL-Shortening-Service is licensed under the GPL-3.0 license.