0

I am writing apidocs for a nodejs project someone else wrote. I would like the documentation page to be displayed when someone visits "myurl.com/docs/api". My documentation directory is being placed under "app/public/app/docs/apidoc/" and I am trying to use routes to display it but gives me an error stating:

'Error: Failed to lookup view "/public/app/apidoc/index.html" in views directory "/Path/To/Project/app/views"'

Here is my routes.js entry:

app.get('/docs/api', function(req, res) {
   res.render('/app/apidoc/index.html');
});

I believe the project uses jade and ejs as they are listed somewhere in the configuration files.

1 Answers1

5

You can serve the documentation from the public folder by using this

app.use(express.static('public'));

And then generate the apidoc with this command

apidoc -e "(node_modules|public)" -o public/apidoc

Now you can access the documentation by navigating to http://{rooturl}/apidoc

HeineSkov
  • 449
  • 1
  • 7
  • 18