Skip to content
/ core Public

static-files-server written in typescript usable as a command-line-tool (or runtime library)

Notifications You must be signed in to change notification settings

chef-js/core

Repository files navigation

chef-core

npm version build status

start cooking!

  • chef-* is a static-files-server
  • written in typescript
  • usable as a command-line-tool (or runtime library)
  • with many tests and continuous-integration
  • optional 404 fallback to index.html with a 200 status code (spa)
  • optional cache
  • optional web-sockets micro-service manager on same port

Express

npm version build status

The most basic flavor of the core library - serve folder. port defaults to 3000

npx chef-express folder

see chef-express for more information about command line parameters

Socket

npm version build status

On top of the base adds socket.io for websockets functionality on the same port.

npx chef-socket folder [--plugin node_modules/chef-socket/chat.js]

see chef-socket to find out more

demo (with chat plugin)

https://chef-socket.pietal.dev/

API Documentation

For detailed API documentation, and types, refer to the chef-core API

To serve the dist folder with express flavor on localhost:443, with development ssl, setting max file cache to 1000 entries:

$ npx chef-express dist --ssl --port 443 --cache 1000

To serve the dist folder with socket flavor on localhost:3000, with a WebSocket plugin, in debug mode:

$ npx chef-socket dist --plugin ./path/to/plugin.js --debug

Configuration

You can read the default configuration by using the following code:

import { config, type Config } from "chef-[core/express/socket]";

Alternatively, you can declare a custom configuration by omitting the values where below defaults suit you:

{
  "folder": ".",      // first parameter of cli
  "port": 3000,       // --port n
  "cache": 0,         // --cache n
  "join": "/join",    // --join /join
  "leave": "/leave",  // --leave /leave
  "plugins": {},      // --plugin path/to/plugin.js
  "spa": false,       // --spa
  "debug": false,     // --debug
  "ssl": null,        // --ssl
}

You can also check the resulting server.config after the server has started.

License

MIT