generator icon indicating copy to clipboard operation
generator copied to clipboard

Improvements to the Generator

Open ritch opened this issue 10 years ago • 5 comments

After a discussion (quite a while ago) with @dougwilson I've been thinking about how we could improve the boilerplate generator for express. The generator itself hasn't really gone through an overhaul since it was converted from a short script that concat'd a bunch of source together and outputted some files into a nice set of templates with improvements to the file structure.

With some large changes to the generator I think we can make express a lot better as a starting point for building your own tailored framework. Right now the choices you have for the generated code are fairly shallow. I think we can expand these choices to include what a lot of people are using express for. The changes are fairly large though.

Here is what I am thinking:

  • A preference file, allowing you to configure every aspect of the generated code. Here is an example
  • A set of templates that you can modify to generate code in your exact style.
  • The executable would take the preferences and templates as input and output an Express app.

Obviously there are a lot of specifics missing and the example preference file is fairly magic looking. So before I go much further with the idea I wanted to test the waters to see if this idea had any merit. Also there might be other ideas / projects underway that do this?

ritch avatar May 21 '15 17:05 ritch

So there is a lot of questions/ideas here, but my main thoughts is yes, this module is pretty bare-bones and really doesn't provide enough value, i.m.o.

dougwilson avatar May 22 '15 01:05 dougwilson

@dougwilson What if we started with:

Input

A preference file - using a format that supports comments.

var $ = exports

// Use Resourceful routing?
$.ROUTING_STYLE = 'resource' // resource.index = function
// ROUTING_STYLE = 'plain' // app.get('/foo')

// What templating engine?
$.TEMPLATING = 'jade'
// TEMPLATING = 'dustjs-linkedin'
// TEMPLATING = 'ejs'

// What css engine?
$.CSS_ENGINE = 'plain css'
// CSS_ENGINE = 'less'
// CSS_ENGINE = 'stylus'
// CSS_ENGINE = 'compass'

// Does this app need to interact with a database or orm?
$.ORM = true
$.ORM_LIB = 'juggler'
// ORM_LIB = 'waterline'
// ORM_LIB = 'sequelize'

// Validation
$.VALIDATION_LIB = 'anchor'
// VALIDATION_LIB = 'juggler'
// VALIDATION_LIB = 'joi'
// VALIDATION_LIB = 'validation.js'

Note: we could even default a lot of the above to false / off to avoid bloating the default usage of express(1)

Source code templates - like what we have now but user customizable/overridable.

Output

Almost exactly like we have now, but with more features:

  • example validation
  • ORM usage example
  • resource routing (using express-resource)

ritch avatar May 26 '15 18:05 ritch

I am open to whatever, in the end :) Anything would be an improvement to this module at this point, lol.

dougwilson avatar May 27 '15 01:05 dougwilson

Just wanted to ping an idea in here about potentially exposing alternative templating engines and possibly using React as a first-class templating flag.

Currently the generator supports jade, hbs, hogan, and ejs. With a library such as consolidate would it be possible to expose more templating engines? Even potentially just removing the flags as a whole and providing a manifest .expressrc file to configure the templating?

In terms of React, considering it renders on the server. Would it be possible to include it with something like react-engine?

ninjasort avatar Aug 07 '15 22:08 ninjasort

@cameronroe if you are gonna ask for React, I am gonna advocate for Vue, not only is it much simpler than React but also has a huge community, ever-growing might I add

slidenerd avatar Oct 29 '20 08:10 slidenerd