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.
The main technologies in this project are:
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"
}
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"
npm install
npm run build:watch
npm run dev
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"
}