Skip to content

jbystronski/jb-fmanager-fastify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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

root

Root folder for the frontend component

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).

errorHandler

To handle errors your way, optional

Example use

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

// including the package

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

// 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();

About

jb file manager endpoint setup for fastify

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published