Skip to content

guardzcom/code-review-exercise

Repository files navigation

Guardz Nodejs Express Server

A Nodejs TypeScript-based Express web server for processing and fetching URLs.

Features

  • Node.js application
  • TypeScript
  • Express.js web server
  • URL validation and processing
  • Axios HTTP requests
  • Req redirect handled by Axios
  • Controller and route architecture
  • No persistent data storage, all urls stored in memory
  • Tested on node version 22.18.0

Installation

Local Installation

  1. Clone the repository
  2. Install dependencies:
npm install

Docker Installation

  1. Clone the repository
  2. Build and run with Docker Compose:
docker compose up --build

Production

Docker Production:

docker pull leonsm/guards-url-fetch
docker run -p 8080:8080 leonsm/guards-url-fetch -i

API Endpoints

URL Processing Routes (/urls)

  • GET /urls - Fetch and process all URLs in the list

    • Returns processed URL data including content, status codes, and headers
    • Handles redirects automatically
    • Returns both successful and failed requests
  • POST /urls - Add URLs to the processing list

    Multiple URLs:

    {
      "urls": ["http://example1.com", "http://example2.com", "http://example3.com"]
    }

curl Examples

Add URLs:

curl -X POST -H "Content-Type: application/json" -d '{"urls": ["http://example.com", "http://google.com"]}' http://localhost:8080/urls

Fetch and process all URLs:

curl http://localhost:8080/urls

Scripts

  • npm run dev - Start development server with nodemon and hot reloading
  • npm run build - Compile TypeScript to JavaScript in dist/ folder
  • npm start - Start production server from compiled JavaScript
  • npm run clean - Remove build directory
  • npm run test - run tests

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published