electron-middle
electron-middle is a way to add middleware behaviour to electron apps
To install, run npm install electron-middle
Example usage
This example will open a window that displays "Hello, world!"
// index.js// Run this file with electron:// electron index.jsconst middle = // This is where the magic happensmiddle { let win = width: 800 height: 600 win}
Usage
middle.get()
takes a function with two arguments, file
and cb
.
file
is the path to the file that electron is trying to access. (As you can see in the example above, the file doesn't need to actually exist).
cb
is a function you must call exactly once, call it with a string or a Buffer if successful, or empty to let the next, or default handler deal with the request.
Example implementation
Here is the main code for electron-middle-pug, a middleware to compile .pug
files to .html
// electron-middle-pug: index.jsconst middle = const pug = const fs = const path = middle { fs}