Skip to content

Merkur39/starter-fastify-api

Repository files navigation

Starter Fastify API

A Node.js TypeScript project with Fastify to create a performant and modern API.

🚀 Features

  • Fastify : Fast and efficient web framework for Node.js
  • TypeScript : Static typing and modern development
  • ESModule : Native ES6 modules support
  • JWT Authentication : JWT authentication support
  • CORS : Cross-Origin Resource Sharing support
  • Cookie Support : Built-in cookie management
  • ESLint : Linting with latest TypeScript rules
  • Prettier : Automatic code formatting
  • Hot Reload : Automatic reload in development with tsx

📋 Prerequisites

  • Node.js 18+
  • npm or yarn

🛠️ Installation

npm install

🚦 Available Scripts

  • npm run dev - Start the server in development mode with hot reload
  • npm run build - Compile TypeScript to JavaScript
  • npm start - Start the server in production mode
  • npm run lint - Check code with ESLint
  • npm run lint:fix - Automatically fix ESLint errors
  • npm run format - Format code with Prettier
  • npm run type-check - Check TypeScript types without compilation

🏃‍♂️ Quick Start

Development mode

npm run dev

Production mode

npm run build
npm start

📡 Available Endpoints

Main API

  • GET /api - API root endpoint with version information

Status

  • GET /api/status - API status with uptime

Authentication

  • POST /api/auth/signup - Sign up (not implemented)
  • POST /api/auth/signin - Sign in (not implemented)
  • POST /api/auth/logout - Logout (not implemented)

🔧 Configuration

The server can be configured via the .env file at the project root and the config folder in the src directory.

📝 Project Structure

starter-fastify-api/
├── src/
│   ├── index.ts              # Main entry point with FastifyAPIStarter class
│   ├── config/
│   │   └── index.ts          # Server configuration
│   ├── routes/
│   │   ├── auth/
│   │   │   └── index.ts      # Authentication routes
│   │   ├── index/
│   │   │   └── index.ts      # Main API route
│   │   └── status/
│   │       └── index.ts      # Status route
│   └── types/
│       └── index.ts          # TypeScript types
├── dist/                     # Compiled code (generated)
├── .prettierrc              # Prettier configuration
├── .prettierignore          # Files ignored by Prettier
├── eslint.config.js         # ESLint configuration (v9)
├── tsconfig.json            # TypeScript configuration
└── package.json             # Dependencies and scripts

🧰 Technologies Used

  • Node.js - JavaScript runtime
  • Fastify 5 - Ultra-fast web framework
  • TypeScript - Programming language
  • @fastify/jwt - JWT plugin for authentication
  • @fastify/cors - CORS plugin
  • @fastify/cookie - Cookie support
  • ESLint 9 - Linter with flat config configuration
  • Prettier 3 - Code formatter
  • tsx - TypeScript runtime for development

License

This project is distributed under the GNU General Public License v3.0.

See the LICENSE file for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published