Skip to content

MomsFriendlyDevCo/Expressy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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.

About

Express with some extra features

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published