smash-middleware-helloworld

raw JSON →
0.0.25 verified Sat Apr 25 auth: no javascript

smash-middleware-helloworld is a middleware for the smash-cli framework, providing a simple hello world example for plugin development. Currently at version 0.0.25, it is part of the smash-cli ecosystem and demonstrates how to create custom middleware. This package is in early development (pre-1.0), with no regular release cadence. It is intended as a learning tool or starting point for building smash-cli middleware. Differentiator: tightly integrated with smash-cli, not suitable for standalone use.

error Error: Cannot find module 'smash-middleware-helloworld'
cause Package not installed or not in NODE_PATH.
fix
Run npm install smash-middleware-helloworld
error TypeError: helloWorld is not a function
cause Using named import or destructured require instead of default import.
fix
Use import helloWorld from 'smash-middleware-helloworld'
error Uncaught SyntaxError: The requested module 'smash-middleware-helloworld' is expected to be of type CommonJS but is an ES module
cause Package is ESM-only, but project uses require() or outdated Node.js version.
fix
Use import syntax or set "type": "module" in package.json. Node.js >=12 required.
gotcha This middleware requires smash-cli version >= 0.9.0. It will crash if used with older versions.
fix Install smash-cli@>=0.9.0.
breaking Version 0.0.20 changed the export from a factory function to a default export. Direct require or import destructuring will break.
fix Use default import: import helloWorld from 'smash-middleware-helloworld'.
deprecated The 'init' method was deprecated in v0.0.10 and removed in v0.0.15. Use the constructor directly.
fix Replace .init() with new middleware instance.
gotcha The middleware does not export TypeScript type definitions. TypeScript users may see 'could not find a declaration file' errors.
fix Add a dummy declaration file: declare module 'smash-middleware-helloworld';
npm install smash-middleware-helloworld
yarn add smash-middleware-helloworld
pnpm add smash-middleware-helloworld

Demonstrates how to create a smash-cli app and add the hello world middleware.

import smash from 'smash-cli';
import helloWorld from 'smash-middleware-helloworld';

const app = smash();
app.use(helloWorld());
app.start();