Coder Social home page Coder Social logo

ghost-blade's Introduction

ghost-blade

A slightly opinionated convenience wrapper for the ghost blog system that lets you use ghost as an express middleware. While being similar to ghost-on-heroku (thanks for the inspiration), it enables you to run ghost on any JS hosting platform.

Installation

npm install ghost-blade

API

ghost-blade exports a function that takes a ghostConfig object and returns a promise of an express middleware. The ghostConfig object is checked for secure production settings and then passed directly to ghost. See all config options at Configuring ghost.

Use the config file examples below as a starter. ghost-blade prohibits insecure settings or settings involving local file storage to enable you to run your blog on popular JS hosting services (e. g. Heroku, Bitnami).

Usage example

// index.js
import express from 'express'
import ghostBlade from 'ghost-blade'
import logger from 'winston'

import config from './config.js'
import ghostConfig from './ghostConfig.js'

var app = express()

ghostBlade({ghostConfig})
    .then(function (ghostBladeMiddleware) {
        app.use('/', ghostBladeMiddleware)
        app.listen(config.server.port, config.server.host, function () {
            logger.info('listening on ' + config.server.host + ':' + config.server.port + ' in ' + process.env.NODE_ENV + ' mode')
        })
    })
    .catch(function (e) {
        logger.error(e)
    })
// config.js
const config = {
    development: {
        server: {
            host: 'localhost',
            port: 1336
        }
    },
    production: {
        url: 'http://yourapp.com',
        server: {
            host: '0.0.0.0',
            port: process.env.PORT || 1336
        }
    }
}

export default config[process.env.NODE_ENV]
// ghostConfig.js
export default {
    development: {
        url: 'http://localhost:1336',
        database: {
            client: 'mysql',
            connection: mysql://user:password@host/database
        }
    },
    production: {
        url: process.env.URL,
        database: {
            client: 'mysql',
            connection: mysql://user:password@host/database
        },
        fileStorage: false,
        forceAdminSSL: true
    }
}

ghost-blade's People

Contributors

erkstruwe avatar

Watchers

James Cloos avatar  avatar

ghost-blade's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.