Skip to content

A Fastify-based API for managing polygons with endpoints to create, retrieve, and delete polygon records. It uses JSON-based storage along with auto-generated Swagger API documentation to facilitate development and testing.

Notifications You must be signed in to change notification settings

harut0111/fastify-polygons

Repository files navigation

Fastify Polygons API

A Fastify-based API for managing polygons with endpoints to create, retrieve, and delete polygon records. It uses JSON-based storage along with auto-generated Swagger API documentation to facilitate development and testing.


Features

  • Fastify Framework
    High-performance Node.js framework for building scalable APIs.

  • LowDB
    Lightweight JSON-based database for simple storage needs.

  • Swagger Documentation
    Auto-generated and interactive API documentation.

  • CORS Support
    Configurable CORS settings to control resource sharing.

  • Dockerized
    Ready-to-use Docker setup for containerized deployment.


Project Structure

.
├── .env                  # Environment variables
├── Dockerfile            # Docker configuration
├── docker-compose.yml    # Docker Compose configuration
├── index.js              # Main application entry point
├── src/
│   ├── config/           # Configuration files
│   ├── db/               # Database setup
│   ├── routes/           # API route handlers
│   ├── schemas/          # JSON schemas for validation
│   └── utils/            # Utility functions
└── package.json          # Project dependencies and scripts

Prerequisites

  • Node.js (v18 or higher)
  • Docker (optional, for containerized deployment)

Installation

1. Clone the repository

git clone https://github.com/harut0111/fastify-polygons.git
cd fastify-polygons

2. Install dependencies

npm install

3. Create a .env file in the project root

PORT=3000
DELAY=1000
DB_FILE_NAME=db.json
CORS_ORIGIN=http://localhost:5173

4. Start the server

npm start

Access the API at http://localhost:3000.


Docker Deployment

For containerized deployment, follow these steps:

Build the Docker image

docker-compose build

Start the container

docker-compose up

Once the container is running, access the API at http://localhost:3000.


Testing & Code Quality

Lint the Code

npm run lint

Format with Prettier

npm run format

Run Tests

npm test

API Documentation

Swagger documentation for the API is available at:
http://localhost:3000/docs

About

A Fastify-based API for managing polygons with endpoints to create, retrieve, and delete polygon records. It uses JSON-based storage along with auto-generated Swagger API documentation to facilitate development and testing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published