{"id":49215,"library":"restafary","title":"restafary","description":"restafary v13.0.4 provides RESTful CRUD operations for file management via HTTP methods (GET, PUT, PATCH, DELETE) on files and directories. It acts as Express middleware, supporting features like sorting, hashing, unzip on upload, and directory creation. Requires Node.js >=22 and depends on express. It is actively maintained with regular releases. Key differentiators: simple integration, raw file access, and diff-based patching.","status":"active","version":"13.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/coderaiser/node-restafary","tags":["javascript","rest","crud","files","middleware"],"install":[{"cmd":"npm install restafary","lang":"bash","label":"npm"},{"cmd":"yarn add restafary","lang":"bash","label":"yarn"},{"cmd":"pnpm add restafary","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; used as middleware with Express application","package":"express","optional":true}],"imports":[{"note":"ESM-only package, cannot use require()","wrong":"const restafary = require('restafary')","symbol":"restafary","correct":"import { restafary } from 'restafary'"},{"note":"Package supports both named and default import","wrong":"const restafary = require('restafary').default","symbol":"default export","correct":"import restafary from 'restafary'"},{"note":"TypeScript types are not exported; options are plain object","wrong":"","symbol":"type import","correct":"import type { RestafaryOptions } from 'restafary'"}],"quickstart":{"code":"import http from 'node:http';\nimport express from 'express';\nimport { restafary } from 'restafary';\n\nconst app = express();\nconst server = http.createServer(app);\n\napp.use(restafary({\n    prefix: '/fs',\n    root: '/',\n}));\n\napp.use(express.static(import.meta.dirname));\nserver.listen(1337, '0.0.0.0');","lang":"typescript","description":"Sets up Express app with restafary middleware to serve files via REST API on /fs prefix."},"warnings":[{"fix":"Use import statements or dynamic import() instead of require()","message":"ESM-only: package is ESM-only since v13, require() will throw ERR_REQUIRE_ESM","severity":"gotcha","affected_versions":">=13.0.0"},{"fix":"Upgrade Node.js to version 22 or higher","message":"Node.js >=22 required: drops support for older Node versions","severity":"breaking","affected_versions":">=13.0.0"},{"fix":"Restrict root to a subdirectory or use a function to validate paths","message":"Root path safety: setting root to '/' allows access to entire filesystem; ensure this is intended","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'22':40 'access':58 'act':23 'activ':47 'base':62 'creation':37 'crud':6,66 'delet':17 'depend':42 'diff':61 'diff-bas':60 'differenti':53 'directori':21,36 'express':25,44 'featur':28 'file':9,19,57,67 'get':14 'hash':31 'http':12 'integr':55 'javascript':64 'key':52 'like':29 'maintain':48 'manag':10 'method':13 'middlewar':26,68 'node.js':39 'oper':7 'patch':16,63 'provid':4 'put':15 'raw':56 'regular':50 'releas':51 'requir':38 'rest':5,65 'restafari':1,2 'simpl':54 'sort':30 'support':27 'unzip':32 'upload':34 'v13.0.4':3 'via':11","created_at":"2026-06-07T17:00:38.419485+00:00","updated_at":"2026-06-07T17:00:38.419485+00:00","problems":[{"fix":"Change to import { restafary } from 'restafary' or use dynamic import()","cause":"Using CommonJS require() to import an ESM-only package","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"},{"fix":"Ensure app is created with express() before use","cause":"Calling app.use() before creating app with express()","error":"TypeError: Cannot read properties of undefined (reading 'use')"},{"fix":"Upgrade Node.js to >=22 or transpile with Babel","cause":"Using nullish coalescing operator in older Node versions","error":"SyntaxError: Unexpected token '??'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/coderaiser/node-restafary","github":"https://github.com/coderaiser/node-restafary","docs":null,"changelog":null,"pypi":null,"npm":"restafary","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}