Skip to content

semizemes/Build-NodeJS-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unusual Destinations API

Lightweight Node.js + HTTP server that serves a curated list of unusual travel destinations from an in-memory dataset.

Prerequisites

  • Node.js 18+ (ESM + top-level await support)

Install & Run Locally

  1. Install deps (none beyond Node standard lib):
npm install
  1. Start the server (defaults to port 8000):
npm start
  1. Override port if needed:
PORT=4000 npm start

API

Base URL: use either the production URL above or your local host/port.

Endpoints

  • GET /api — all destinations (with optional query parameters).
  • GET /api/continent/:name — destinations filtered by continent. Hyphens are normalized to spaces so /api/continent/north-america matches "North America".
  • GET /api/country/:name — destinations filtered by country. Hyphens are also normalized.

Query Parameters

Filter results using query parameters with /api:

  • continent — filter by continent (e.g., ?continent=north-america)
  • country — filter by country (e.g., ?country=usa)
  • is_open_to_public — filter by public access status (e.g., ?is_open_to_public=true or ?is_open_to_public=false)

Parameters can be combined: ?continent=europe&is_open_to_public=true

Example Requests (Production)

Responses are JSON arrays of destination objects shaped like:

{
  "name": "Fly Geyser",
  "location": "Nevada",
  "country": "USA",
  "continent": "North America",
  "is_open_to_public": false,
  "uuid": "550e8400-e29b-41d4-a716-446655440005",
  "details": [
    { "fun_fact": "The geyser was accidentally created by well drilling in 1964." },
    { "description": "A colorful, continuously spouting geothermal formation with vibrant mineral deposits on a private Nevada ranch." }
  ]
}

Structure

  • server.js — HTTP server and routing.
  • database/db.js — fetches in-memory dataset.
  • data/data.js — static destination data.
  • utils/sendJSONResponse.js — helper for JSON responses.
  • utils/getDataByPathParams.js — shared filter helper for continent/country routes.

About

Lightweight Node.js REST API that serves JSON from a local dataset with simple path/query filtering utilities and a ready-to-deploy Procfile.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors