@jb_fmanager/fastify

1.0.4 • Public • Published

@jb_fmanager/react setup for fastify

Installation

Include the routes and the utility package @jb_fmanager/node-utils

npm i @jb_fmanager/fastify @jb_fmanager/node-utils

yarn add @jb_fmanager/fastify @jb_fmanager/node-utils

Options

prefix

Must match the namespace provided to the manager, default is "api/fm".

maxUploadSize

If you want to override the value provided to the manager. Accepts bytes, ie 5242880 (5mb).

Example use
const fastify = require("fastify")({ logger: true });
const path = require("path");

// including the package

require("@jb_fmanager/fastify")(fastify, { prefix: "/api/fm" });

// registering static files

fastify.register((instance, opts, next) => {
  instance.register(require("@fastify/static"), {
    root: path.join(__dirname, "public"),
    prefix: "/media",
  });
  next();
});

// including cors plugin

fastify.register(require("@fastify/cors"), {});

const start = async () => {
  try {
    await fastify.listen({ port: 4000 });
  } catch (error) {
    fastify.log.error(error);
  }
};

start();

Readme

Keywords

none

Package Sidebar

Install

npm i @jb_fmanager/fastify

Weekly Downloads

0

Version

1.0.4

License

ISC

Unpacked Size

3.56 kB

Total Files

3

Last publish

Collaborators

  • pogodisco