Skip to content

Matheus1714/url-shortener-api

Repository files navigation

URL Shortener

url-shortener

API SHORTENER is a project that is a solution as the challenge of the Bootcamp Eduzz Fullstack Developer program offered by DIO (dio.me). It is a dynamic API harnesses the power of TypeScript and Node.js to provide a solution for aspiring fullstack developers.

Technologies

The main technologies in this project are:

Dependencies

The dependencies used are:

"dependencies": {
    "@hasezoey/typegoose": "^5.9.2",
    "@typescript-eslint/eslint-plugin": "^4.0.1",
    "@typescript-eslint/parser": "^4.0.1",
    "cors": "^2.8.5",
    "dotenv": "^16.3.1",
    "eslint": "^7.8.1",
    "express": "^4.17.1",
    "mongoose": "5.10.5",
    "nodemon": "^2.0.4",
    "shortid": "^2.2.15",
    "tslint": "^6.1.3",
    "typescript": "^4.0.2"
},
"devDependencies": {
    "@types/express": "4.17.8",
    "@types/mongoose": "5.10.5",
    "@types/shortid": "0.0.29"
}

Database

Before run this project, create a file .env and copy the information from .env.example. Config the variable MONGO_CONNECTION based your cluster create from MongoDB or use the docker-compose.yaml create the database.

[Docker Compose]

version: '3'
services:
  mongodb:
    image: mongo:latest
    container_name: mongodb
    ports:
      - "27017:27017"
    volumes:
      - ./data:/data/db
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: UW6vZjBz7HTwVdyfMAGCRY
docker compose up

[ENV]

Config the enviroment variable.

MONGO_CONNECTION="..."
API_URL="http://localhost:5000"

Start Project

Install Dependencies

npm install

Build Typescript

npm run build:watch

Start Project

npm run dev

Test API

To test the API, POST to the /shorten route using the terminal or Postman.

[REST Client]

@base_url=http://localhost:5000

###

# shortener

POST {{base_url}}/shorten
content-type: application/json

{
    "originURL": "https://www.youtube.com/watch?v=9X7I3bW49S8&ab_channel=CamelliaOfficial"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published