examples icon indicating copy to clipboard operation
examples copied to clipboard

wishlist: Express examples

Open bnb opened this issue 5 years ago • 9 comments

It would be genuinely wonderful to get some examples of Express into the examples repo's servers examples.

Ideally, these examples will:

  • Go beyond a simple "Hello, World"
  • Include tests
  • Have a README that explains what the project does and how to use it.

Please see CONTRIBUTING.md for more context on how to contribute. Please feel free to ask any questions here ❤️

bnb avatar Jul 07 '20 17:07 bnb

I am happy to contribute here.

gireeshpunathil avatar Jul 08 '20 03:07 gireeshpunathil

Yay! If you have any questions @gireeshpunathil, more than happy to do what I can to help get you going 👍

bnb avatar Jul 08 '20 15:07 bnb

to start with, here is what I think the app could contain:

  • a (GET) route which yields a simple response such as the current time in UTC
  • a (GET) route which is enabled with session
  • a (POST) route that runs a file upload function
  • a (GET) route which fetches and process some data from some db
  • a (GET) route that forwards the request to another route

and some tests. let me know WDYT!

gireeshpunathil avatar Jul 09 '20 04:07 gireeshpunathil

that sounds good to me, though I'm not sure if fetching data from a database is meaningfully testable in CI. More than happy to be wrong!

bnb avatar Jul 09 '20 16:07 bnb

my idea was to look for an in-memory db for this purpose: while not making things too complex, and still caters to a very common programming scenario.

gireeshpunathil avatar Jul 09 '20 16:07 gireeshpunathil

sounds good to me :)

bnb avatar Jul 10 '20 15:07 bnb

Maybe it would be worth to include examples in other frameworks (like Koa or Nest) as well as a server in pure Node.js just to show the difference and pros/cons of each approach?

I believe there could be some situations where using pure Node would make a perfect sense. What do you think?

ghost avatar Jul 13 '20 15:07 ghost

@iandrc The intent of this repository is to include many different kinds of examples. I'd look at it less as a pros/cons comparison and more of a way to demonstrate how things work in general. Ideally, with enough examples, the similarities and differences could be figured out by reading/running those difference examples.

bnb avatar Jul 13 '20 22:07 bnb

I've got some working examples with mongodb and mysql2. Sorry late to party here and very new too contributing altogether.

trevatk avatar Oct 12 '20 16:10 trevatk