Mithgol / node-gamayun

A server that serves answers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(a histogram of downloads)

This module (gamayun) is a server that serves answers.

It is named after a prophetic bird of Russian folklore.

It is designed as a web application for the Express.js web server.

This module is currently in an early phase of its development and thus does not have the desired level of feature completeness.

Goals

Long-term goal: a server where people ask their questions and the user replies (like Ask.fm, or like former Spring.me before it was converted to a dating service). Instead of a centralized approach, this should be installable on personal servers (such as Krylov's answers, but with open source).

Short-term goal: a server that is able to host answers imported by the autumn package from Spring.me servers.

Installing Gamayun

(npm package version)

  • Latest packaged version: npm install gamayun

  • Latest githubbed version: npm install https://github.com/Mithgol/node-gamayun/tarball/master

You may visit https://github.com/Mithgol/node-gamayun#readme occasionally to read the latest README because the package's version is not planned to grow after changes when they happen in README only. (And npm publish --force is forbidden nowadays.)

**Note: ** Express.js dependency is declared in peerDependencies section and thus it won't be automatically installed by npm version 3 (or newer) when you install Gamayun. You are expected to install (separately) both Express and Gamayun as the dependencies of your own web server.

Using Gamayun

When you require() the installed module, you get a function that accepts an object of options and returns an Express.js application (Gamayun).

**Example 1. ** You may serve the Gamayun application on a route (path) of your Express-based web server:

var express = require('express');
var app = express();

var Gamayun = require('gamayun')(options_for_Gamayun);
app.use('/gamayun', Gamayun);

**Example 2. ** You may also use the vhost module to serve the Gamayun application on a virtual host of your Express-based web server:

var vhost = require('vhost');
var express = require('express');
var app = express();

var Gamayun = require('gamayun')(options_for_Gamayun);
app.use(vhost('gamayun.example.org', Gamayun));

**Example 3. ** You may also directly use the Gamayun application itself as your Express-based web server (if that server's only purpose is Gamayun).

HTTP example:

require('gamayun')(options_for_Gamayun).listen(80);

HTTPS example:

var fs = require('fs');

require('https').createServer(
   {
      key:   fs.readFileSync('somepath/server.key'),
      cert:  fs.readFileSync('somepath/server.crt'),
      honorCipherOrder: true
   },
   require('gamayun')(options_for_Gamayun)
).listen(443);

**Note. ** You should create a configuration file for the installed Gamayun before you use it. (See below.)

Configuration options

The options_for_Gamayun object that is given to Gamayun currently has only one property:

  • configFilePath — the path to the configuration file. That file contains most of the other configuration options in their text form, one line per option. (By default it is the file gamayun.conf in the directory of Gamayun. You may use gamayun.conf-example as an example.)

The configuration file is read only once (when the server starts).

The following configuration option is supported:

  • AutumnUser, followed by a (space-separated) username, followed by a (space-separated) filename or path (which is treated as relative to the configFilePath). This configuration line announces a username of a former Formspring's user and a location of former answers (exported from Formspring by the Autumn tool, beforehand). Several AutumnUser lines are supported (if a Gamayun server is intended to host exported answers of several former Formspring's users).

Testing Gamayun

(build testing status)

It is necessary to install JSHint for testing.

  • You may install JSHint globally (npm install jshint -g) or locally (npm install jshint in the directory of Gamayun).

After that you may run npm test (in the directory of Gamayun). Only the JS code errors are caught; the code's behaviour is not tested.

License

MIT license (see the LICENSE file).

About

A server that serves answers.

License:MIT License


Languages

Language:JavaScript 100.0%