nabeel-ahmad / express-mongoose-docs

Auto-generated Documentation for Express and Mongoose based APIs
Other
38 stars 20 forks source link

Dont show any routes #2

Closed rubenmoya closed 10 years ago

rubenmoya commented 10 years ago

Hi, I followed the steps on the read.me, but when i go to http://127.0.0.1:3000/apiDocs/ there only appear the "Routes" tab empty.

What can I do?

santimacia commented 10 years ago

Have you written the code in the correct order?

rubenmoya commented 10 years ago

Im not sure, here is my app.coffee

express = require("express")
path = require("path")
logger = require("morgan")
cookieParser = require("cookie-parser")
bodyParser = require("body-parser")
mongoose = require("mongoose")
nconf = require("nconf")
docs = require("express-mongoose-docs")
app = express()

#loads the configuration
nconf.argv().env().file file: "./config/" + app.get("env") + ".json"

# view engine setup
app.use logger("dev")
app.use bodyParser.json()
app.use bodyParser.urlencoded()
app.use cookieParser()

#database connection
mongoUri = process.env.MONGOHQ_URL or 'mongodb://localhost/cheers';
mongoose.connect mongoUri, (err, res) ->
    if err
      console.log('ERROR: connecting to Database.')
    else
      console.log('Connected to Database');

#included files
app.use "/", require("./routes/index")
app.use "/strokes", require("./routes/strokes")
app.use "/auth", require("./routes/auth")

docs(app, mongoose);

#/ catch 404 and forward to error handler
app.use (req, res, next) ->
  err = new Error("Not Found")
  err.status = 404
  next err
  return

#/ error handlers

# development error handler
# will print stacktrace
if app.get("env") is "development"
  app.use (err, req, res, next) ->
    res.status err.status or 500
    res.send err.message

    return

# production error handler
# no stacktraces leaked to user
app.use (err, req, res, next) ->
  res.status err.status or 500
  res.send err.message

  return

#starting the server
debug = require("debug")("cheers-api")
app.set "port", process.env.PORT or 3000
server = app.listen(app.get("port"), ->
  debug "Express server listening on port " + server.address().port
  return
)
kfatehi commented 10 years ago

i get the same issue. my project is https://github.com/keyvanfatehi/mib

nabeel-ahmad commented 10 years ago

This module was created for express 3.x and due to major changes in express 4.x the routes are not appearing. I'm going to update this module when I get some time. Meanwhile pull requests are welcome.

andyskw commented 10 years ago

I'm glad to help if I can! :)

dzsessona commented 10 years ago

app._router.stack should be the place to get regitered routes in express 4

MuslimMunir commented 10 years ago

now this module is updated you can now use this module with express 4.x too