Skip to content

Repository files navigation

x402-hackson-data

Nest Logo

Description

Demo project. NestJS v11 backend service that fetches data from all available SkillsMP APIs.

All SkillsMP APIs Implemented:

  • Keyword Search (GET /skills/search) - Search skills using text queries with pagination
  • AI Semantic Search (GET /skills/ai-search) - AI-powered semantic search (Cloudflare AI)

Installation

# Install dependencies
npm install

# Setup environment variables
cp .env.example .env
# Edit .env with your API key

Environment Variables

SKILLSMP_API_KEY=sk_live_your_api_key_here
SKILLSMP_API_URL=https://skillsmp.com/api/v1
PORT=3000

Running

# Development
npm run start:dev

# Production
npm run build
npm run start:prod

API Endpoints

GET /skills/search

Search skills using keywords with pagination.

Parameters:

Param Type Required Description
q string Search query
page number Page number (default: 1)
limit number Items per page (default: 20, max: 100)
sortBy string Sort: stars or recent

Example:

curl "http://localhost:3000/skills/search?q=SEO&page=1&limit=20&sortBy=stars"

Response:

{
  "success": true,
  "data": {
    "skills": [
      {
        "id": "123",
        "name": "SEO Optimizer",
        "description": "Optimize your website",
        "stars": 45,
        "updatedAt": "2024-01-15T10:30:00Z"
      }
    ],
    "pagination": {
      "page":1,
      "limit": 20,
      "total": 150
    }
  }
}

GET /skills/ai-search

AI semantic search powered by Cloudflare AI.

Parameters:

Param Type Required Description
q string AI search query

Example:

curl "http://localhost:3000/skills/ai-search?q=How+to+create+a+web+scraper"

Response:

{
  "success": true,
  "data": {
    "data": [
      {
        "file_id": "...",
        "score": 0.72,
        "skill": {
          "id": "456",
          "name": "Web Scraper Pro",
          "description": "Advanced web scraping with AI",
          "stars": 78
        }
      }
    ]
  }
}

Integration Tests

E2E Tests (Jest)

Tests API endpoints with debug logging.

npm run test:e2e

E2E Tests (Bash/curl)

Manual testing script using curl commands with full request/response logging.

Purpose: Test all endpoints using bash curl commands with complete debug output, including request URLs(api) and response data/error for developers to integrate and verify.

Usage:

# Start server first
npm run start:dev

# Run bash test script
./test/e2e_bash.test.sh

What it logs:

  • Full request URL with all parameters
  • HTTP response status
  • Response success flag
  • Returned data (count, pagination, first result)
  • Error details (if applicable)

Note: Review debug logs to verify full request URLs and responses.

Test Coverage

GET /skills/search (5 tests):

  • Required parameter only
  • With pagination (page, limit)
  • With all parameters combined
  • Empty results when no matches
  • Invalid sortBy value handling

GET /skills/ai-search (4 tests):

  • Valid query
  • Short query
  • Long query
  • Missing query parameter

Error Responses

All errors follow this format:

{
  "success": false,
  "error": {
    "code": "INVALID_API_KEY",
    "message": "The provided API key is invalid"
  }
}

Error Codes:

Code HTTP Description
MISSING_API_KEY 401 API key not provided
INVALID_API_KEY 401 Invalid API key
MISSING_QUERY 400 Missing required query parameter
INTERNAL_ERROR 500 Internal server error

Development

# Build
npm run build

# Format
npm run format

# Lint
npm run lint

# Test
npm run test

Project Structure

src/modules/skills/
├── skills.controller.ts    # HTTP endpoints
├── skills.service.ts       # SkillsMP API client
├── skills.dto.ts           # TypeScript types
└── skills.module.ts        # NestJS module

API Documentation

License

UNLICENSED

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages