Skip to content

Proposal: expose Ghost as reusable express middleware #827

@nicoburns

Description

@nicoburns

It would be cool if Ghost could be installed as an npm module, and then used as middleware in any express app. So you could do something like:

var express = require("express");
var ghost = require("ghost");

var app = express();

app.get('/', function(req, res) {
  res.send('hello world');
});

var blog = ghost({
    contentDirectory: "./ghost-blog-content"
});

app.use(blog.middleware({
    urlRoot: "/blog"
}));

app.listen(3000);

Notably both the content directory, and the url it is served from are configurable here. It could also be interesting to experiment with allowing the front-end, admin interface and public API to all be served from separate custom locations.

This would allow all sorts of possibilities such as having multiple Ghost blogs in the same server, and embedding ghost as part of a larger CMS product... Obviously this would need to be in addition to it working standalone, but I don't think that would be too difficult to manage (the standalone version could just be a thin wrapper around the middleware version).

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects:serverIssues relating to the server or core of Ghost

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions