Skip to content

rasulovdev/copaco-backend-assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interview backend (interview-app)

Small Fastify + GraphQL Yoga service that uses Open-Meteo (geocoding + forecast, no API key) for weather by city, and API Ninjas for the dictionary, plus a tiny in-memory webhook debug API.

Prerequisites

  • Node.js 20+
  • pnpm (or adapt commands for your package manager)

Setup

pnpm install
cp .env.example .env

Edit .env and set API_NINJAS_API_KEY from your API Ninjas account.

Run

pnpm dev

The server listens on PORT from the environment (default 3000).

Scripts

Script Description
pnpm dev tsx watch mode
pnpm start single run
pnpm test Vitest
pnpm typecheck tsc --noEmit

Environment variables

Name Required Description
API_NINJAS_API_KEY Yes X-Api-Key for dictionary calls to api.api-ninjas.com only (weather does not use it)
PORT No HTTP port (default 3000)
LOG_LEVEL No Optional; consumed when creating the stdout-backed logger (src/lib/logger.ts)

Example requests

Health

curl -sS http://localhost:3000/healthcheck

GraphQL (POST /graphql)

Dictionary (works with a valid API key):

curl -sS http://localhost:3000/graphql \
  -H 'content-type: application/json' \
  --data-binary '{"query":"{ dictionary(word: \"computer\") { word valid definition } }"}'

Composite insights (uses both upstream endpoints):

curl -sS http://localhost:3000/graphql \
  -H 'content-type: application/json' \
  --data-binary '{"query":"{ insights(input: { city: \"Amsterdam\", word: \"computer\" }) { summary weather { city tempC humidity windKph } dictionary { word valid definition } } }"}'

Weather-only query

curl -sS http://localhost:3000/graphql \
  -H 'content-type: application/json' \
  --data-binary '{"query":"{ weatherByCity(city: \"Amsterdam\") { city tempC humidity windKph } }"}'

REST

Ingest webhook

curl -sS http://localhost:3000/webhook/events \
  -H 'content-type: application/json' \
  --data-binary '{"type":"order.created","payload":{"id":123}}'

Debug: last 10 webhook events

curl -sS http://localhost:3000/debug/state

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors