@momsfriendlydevco/expressy

1.0.5 • Public • Published

@MomsFriendlyDevCo/Expressy

ExpressJS with some extra functionality:

  • File watch support
  • Hot-swap routing - can rebuild routes on the fly for single file changes without rebooting the whole stack
  • Doop-ESM loader support
  • Out-of-the-box base middleware

To use the Expressy module with the Doop-ESM loader see the instructions in @Doop/ESM-Loader.

Example - Simple web server

import Expressy from '@momsfriendlydevco/expressy';

new Expressy()
	.use(bodyParser.json())
	.use((req, res, next) => {
	  // Example middleware injection
	  next();
	})
	.get('/api/widgets', (req, res) => res.send(widgets))
	.get('/api/widgets/:id', (req, res) => res.send(widgets.find(w => w.id == req.params.id)))
	.post('/api/widgets/:id', (req, res) => {
	  return res.send({
		...widgets.find(w => w.id == req.params.id),
		...req.body,
	  });
	})
	.delete('/api/widgets/:id', (req, res) => res.send(
	  widgets = widgets.filter(w => w.id != req.params.id)
	))

Base middleware

This module automatically loads various Express middleware when booting a server.

Configure expressy.commonMiddleware (defaults in commonMiddleware.js) to change whether certain items are loaded and with what options.

Dependencies (13)

Dev Dependencies (6)

Package Sidebar

Install

npm i @momsfriendlydevco/expressy

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

22.7 kB

Total Files

9

Last publish

Collaborators

  • hash-bang
  • 1watt
  • eekthecat
  • melromero
  • mr-yellow