Skip to content

A RESTful URL shortener built with NestJS, TypeScript, and MongoDB.

License

Notifications You must be signed in to change notification settings

christophermilian/nestjs-url-shortener

Repository files navigation

Description

A Nest based url shortener written in TypeScript and leveraging MongoDB for storage.

System Overview

alt text

Available Endpoints

  1. POST: http://localhost:3000/create-url

    Payload:

    {
    "longUrl": "https://www.linkedin.com/in/christophermilian/"
    }
    
  2. GET: http://localhost:3000/{generatedCode}

  • Must be entered in a browser for proper redirection

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Local MongoDB Setup

# Install MongoDB via Homebrew
brew tap mongodb/brew

# Update brew packages
brew update

# Install mongodb
brew install mongodb-community@7.0

Before running mongosh, you need to create an admin user to secure the connection. Steps for creating an admin user can be found here, Authenticate with SCRAM

# run mongod authenticated
mongod --auth --port 27017 --dbpath /opt/homebrew/var/mongodb

# run mongosh with admin (please use unique user and password)
mongosh --port 27017  --authenticationDatabase "admin" -u "myUserAdmin" -p

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

License

MIT licensed

About

A RESTful URL shortener built with NestJS, TypeScript, and MongoDB.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published