mere-server
Serve HTML or JSON
$ npm install --save mere-server
Hello World Server
const mereServer = ; const routes = route: '/hello-world' { return '<h1>Hello World</h1>' } route: '/users-table' bodyCb: route: '/add-user' bodyCb: method: 'POST' responseType: 'JSON' ; mereServer;
Custom Route Handlers
Streaming video
const mereServer = ;const fs = ; { server;} const routes = route: '/' { return `<h1>Video Stream Demo</h1> <video controls src="http://localhost:8080/video-stream"/>`; } method: 'GET' // GET /video-stream will be handled by the streamVideo function route: '/video-stream' method: 'GET' responseType: 'video/mp4' ; mereServer;
Deploy with cron job:
@reboot cd /home/you/path/to/your-mere-server && /home/you/.nvm/versions/node/v10.15.3/bin/node index.js 3456