Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kagchi/fasting

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kagchi/fasting

A Better Fastify auto loads for Routes & Prehandlers

  • 1.2.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
37
decreased by-56.98%
Maintainers
0
Weekly downloads
 
Created
Source
Logo

@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!");
    }
}

Keywords

FAQs

Package last updated on 27 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc