donejs / done-serve

DoneJS development server
https://www.npmjs.com/package/done-serve
MIT License
7 stars 5 forks source link

Add a middleware #35

Open BigAB opened 7 years ago

BigAB commented 7 years ago

I don't know if this is a common issue, but right now I needed to start a DoneJS app, and I need to add one little middleware to the project. (in this case an custom-auth middleware)

So, currently, to make that work, and still enjoy the benefits of the live-reloading, server-rendering, SPA'ing done-serve stuff, I basically had to copy-pasta all the done-serve code into a server.js file, and run that instead. Not horrible, but I feel it would be a lot cooler if I could just set some config or something donejs add middleware my-middleware and have it work out for me.

I know it doesn't have this right now but...

sure-would

matthewp commented 7 years ago

:D Another alternative would be to spin off the live-reload and other stuff into some type of middlewary thing that could be consumed more easily without the copy pasting.

matthewp commented 7 years ago

Also note that done-serve is a development server. I'm wary of adding features that might cause people to depend on it, and use it in production.

frank-dspeed commented 7 years ago

@matthewp @BigAB wouldnt the proxy feature be here the right method? create a little express middelware server and then use the proxy option over that ?

matthewp commented 5 years ago

With the new version of done-serve (3.0) you can provide a configure function which allows you to directly insert middleware. This is what place-my-order does now. However this needs to be documented.