2.0.0 • Published 10 months ago

@kagchi/fasting v2.0.0

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
10 months ago

@kagchi/fasting

A Better Fastify auto loads for Routes & Prehandlers

GitHub Discord

Installation

pnpm

pnpm add @kagchi/fasting

npm

npm i @kagchi/fasting

yarn

yarn add @kagchi/fasting

Example Use

Main file

src/index.ts

import { fasting } from "@kagchi/fasting";
import fastify from "fastify";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";

const fastifyApp = fastify({
    logger: true
});

await fastifyApp.register(fasting, {
    basePath: resolve(dirname(fileURLToPath(import.meta.url)))
});

await fastifyApp.listen({ port: 3_000 })
    .then(() => console.log("Server is running on port 3000"))
    .catch(() => console.log("Server failed to start"));

Create routes folder & Create root route

src/routes/index.ts

import type { RouteOptions } from "@kagchi/fasting";
import { Route } from "@kagchi/fasting";
import type { LoaderPieceContext } from "@sapphire/pieces";
import type { FastifyReply, FastifyRequest } from "fastify";

export class Root extends Route {
    public constructor(context: LoaderPieceContext, options: RouteOptions) {
        super(context, {
            ...options,
            method: "GET",
            path: "/"
        });
    }

    public run(request: FastifyRequest, response: FastifyReply): FastifyReply {
        return response.send("Hello, world!");
    }
}
2.0.0

10 months ago

1.2.0

1 year ago

1.2.8

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.9

12 months ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago