Giter VIP home page Giter VIP logo

fastify-boilerplate's Introduction

vite-fastify-boilerplate

GitHub license GitHub package.json version GitHub issues Coverage Status Sync Vulnerabilities Status Twitter

Enhance your Fastify DX with the power of Vite & Vitest.

Features

  • ⚡ All the power of Vite (Next Generation Frontend Isomorphic Tooling):
    • Lightning fast HMR (hot module replacement) in dev mode with Vite Plugin Node.
    • Smart & instant watch mode, like HMR for tests with Vitest.
  • 🛠️  DX setup:
    • Vite, Prettier and Typescript with common config, esnext ready and alias @/*
    • Tests with one Fastify instance setup, code coverage
    • Fastify with logger
    • Production build without Vite

So, it's super fast donc ça va super vite 🚀

Why and How

See Why and How Vite in node and Why Vitest.

Get started

  1. Clone this repo or use tiged with:
degit https://github.com/ManUtopiK/vite-fastify-boilerplate
  1. Install:
pnpm install

Start dev mode using Vite:

pnpm dev

Start test mode using Vitest:

pnpm test

Start test mode with coverage:

pnpm coverage

Compile typescript to javascript:

pnpm build

Start for production:

pnpm start

Code

  • Main file: src/app.ts
  • Configure logger: src/logger.ts
  • Change port in .env

Docs

Ressources

Add vite plugin example

Import .gql and .graphql files

  1. Install packages:

    pnpm add graphql graphql-tag
    pnpm add -D vite-plugin-simple-gql
  2. Configure vite.config.ts:

    import gql from 'vite-plugin-simple-gql'

    And add gql() to plugins:

    plugins: [gql(), ...]

Now you can import your graphql files in your code:

// example.ts
import MyQuery from './MyQuery.gql'

Contributions

If you would like to make any contribution you are welcome to do so.

Known issues

  • @fastify/autoload doesn't work.
  • Websockets doesn't work with vite-plugin-node. See here. To develop with websockets, you should start Fastify as usual.
  • Vitest UI doesn't work.

Please create an issue if you found any bugs, to help me improve this project!

fastify-boilerplate's People

Contributors

manutopik avatar wd-david avatar dependabot[bot] avatar snyk-bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.