Registry / devops / restafary

restafary

JSON →
library13.0.4jsnpmunverified

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.

npm install restafary
INSTALL
IMPORT
SIG · RESTAFARY
R
restafary
devopsjavascriptv13.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

restafary
✓ import { restafary } from 'restafary'
✗ const restafary = require('restafary')
ESM-only package, cannot use require()
default export
✓ import restafary from 'restafary'
✗ const restafary = require('restafary').default
Package supports both named and default import
type import
✓ import type { RestafaryOptions } from 'restafary'
TypeScript types are not exported; options are plain object

Sets up Express app with restafary middleware to serve files via REST API on /fs prefix.

import http from 'node:http'; import express from 'express'; import { restafary } from 'restafary'; const app = express(); const server = http.createServer(app); app.use(restafary({ prefix: '/fs', root: '/', })); app.use(express.static(import.meta.dirname)); server.listen(1337, '0.0.0.0');
Debug
Known issues
gotchaESM-only: package is ESM-only since v13, require() will throw ERR_REQUIRE_ESM
fix
Use import statements or dynamic import() instead of require()
affects: >=13.0.0
breakingNode.js >=22 required: drops support for older Node versions
fix
Upgrade Node.js to version 22 or higher
affects: >=13.0.0
gotchaRoot path safety: setting root to '/' allows access to entire filesystem; ensure this is intended
fix
Restrict root to a subdirectory or use a function to validate paths
affects: >=0.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using CommonJS require() to import an ESM-only package
fix
Change to import { restafary } from 'restafary' or use dynamic import()
TypeError: Cannot read properties of undefined (reading 'use')
Calling app.use() before creating app with express()
fix
Ensure app is created with express() before use
SyntaxError: Unexpected token '??'
Using nullish coalescing operator in older Node versions
fix
Upgrade Node.js to >=22 or transpile with Babel
Upgrade
Version history
13.0.4latest on npm
Audit
Dependencies
expressoptionalPeer dependency; used as middleware with Express application
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
restafary — npm install restafary · libregistry