shanahanjrs
shanahanjrs

Reputation: 1

Nodejs/apidocjs: How do I render the generated documentation at a specific url without a template

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.

Upvotes: 0

Views: 2325

Answers (1)

HeineSkov
HeineSkov

Reputation: 449

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

Upvotes: 5

Related Questions