generator icon indicating copy to clipboard operation
generator copied to clipboard

Express generator with RESTful crud

Open jacobmumm opened this issue 14 years ago • 3 comments

https://github.com/jacobmumm/generators/tree/express

@blai is working on getting yeoman server to launch a project-local app script through the Gruntfile. I will have to incorporate whatever changes are necessary in the Gruntfile in order for this to work seamlessly.

I wanted to share what I've done so far to see if it makes sense and to get some feedback. Here's how I would use it.

I would start by creating a client-side app. The express generator can be run on top of this. Angular is my framework of choice, so I would do this:

yeoman init angular yeoman init express

I have a pull request in now for angular:crud, and my express generator also has crud.

yeoman init angular:crud post creates: app/scripts/controllers/post/postIndex.js app/scripts/controllers/post/postCreate.js app/scripts/controllers/post/postUpdate.js app/scripts/controllers/post/postView.js app/views/post/postIndex.html app/views/post/postCreate.html app/views/post/postUpdate.html app/views/post/postView.html adds routes to app.js /post/index /post/create /post/update/:id /post/view/:id

yeoman init express:crud post creates: routes/postRoutes.js app.get("/posts", function(req,res){}); app.get("/post/:id", function(req,res){}); app.post("/posts", function(req,res){}); app.put("/post/:id", function(req,res){}); app.delete("/post/:id", function(req,res){});

adds routes to appRouter.js require('routes/postRoutes')(app);

Obviously, a lot needs to be done still, but I just wanted to share this in case anyone else was thinking about doing the same.

//cc @btford

jacobmumm avatar Oct 17 '12 15:10 jacobmumm

I would definitely use this & @blai's server script.

rdrey avatar Oct 30 '12 23:10 rdrey

cc @mklabs

addyosmani avatar Oct 31 '12 10:10 addyosmani

@jacobmumm I'm very interested in playing around with your Express CRUD generator today to see how well the overall workflow fits with a Yeoman client-side app generator. I'm thinking through what the rest of the expected workflow is.

I guess expectations are..

yeoman init angular
yeoman init express
yeoman server (uses express middleware, LiveReload just works)
yeoman build 
yeoman test 

all continue working.

Obviously Express needs to work correctly with our server and folks will want LiveReload support, which @mklabs demonstrated as working in his gist. Is your generator in a usable state at present?

I'm aware we closed https://github.com/yeoman/yeoman/pull/641 for now, but I'm wondering if there's enough between the work you, @blai and @mklabs have done to get a proper POC guide/project together that we can build on.

As @sindresorhus mentioned in other tickets, Yeoman is currently being rewritten but much of the work on the generators should be backwards compatible.

cc @blai

@btford I've read a few issues on StackOverflow where you've been advising developers about getting Express + Yeoman + Angular working together and any input (or code examples/demos) you might have would also be valuable to the discussion.

addyosmani avatar Jan 10 '13 13:01 addyosmani