Last active
May 17, 2024 02:19
-
-
Save kelsin/eaa41c672684ffccdacc to your computer and use it in GitHub Desktop.
Sample express app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
// Load routes | |
require('./src/routes')(app); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = require('../db.js'); | |
modules.exports.index = function(req,res) { | |
res.render('issues/index', {issues: client.issues}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var issues = require('./controllers/issues'); | |
module.exports = function(app){ | |
app.get( '/issues', issues.index); | |
app.get( '/issues/new', issues.new); | |
app.post('/issues', issues.create); | |
app.get( '/issues/:id', issues.show); | |
app.get( '/issues/:id/edit', issues.edit); | |
app.put( '/issues/:id', issues.update); | |
app.del( '/issues/:id', issues.delete); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, I wrote something similar in Coffeescript for my media manager thing. Also, Express 4.x uses a different syntax for fancy routing, although I don't think the way in your example is broken or deprecated.
in routes.coffee
in server.coffee
in controllers/foo.coffee
And here's the code to auto-wire-up all files in controllers/*