Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Fabric #157

Open
wants to merge 24 commits into
base: tatami
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
674913c
Add test code for Fabric.
martindale Aug 3, 2015
5864fdc
Patch minor issue with lack of seeds.
martindale Aug 3, 2015
a0ab6ee
Fix backbone to have listening port.
martindale Aug 3, 2015
8a798e2
Add config value for Fabric port.
martindale Aug 3, 2015
aaca6d8
Commit early morning nightmares.
martindale Aug 3, 2015
e26a478
Merge branch 'master' into fabric
martindale Aug 7, 2015
3589e8b
Add net-browserify socket proxy.
martindale Aug 7, 2015
575b7ef
Add support for parsed Slack messages.
martindale Jul 17, 2016
cd7e3d9
Grammar fixes
LawOfTheLand Jul 11, 2017
550639b
Merge pull request #150 from LawOfTheLand/patch-2
martindale Aug 10, 2018
b60e8e6
Merge remote-tracking branch 'origin/maki.io' into release-0.3
martindale Aug 10, 2018
87c999d
Merge remote-tracking branch 'upstream/community' into release-0.3
martindale Aug 10, 2018
004c42a
Switch book to prefer edits on release branch
martindale Aug 11, 2018
1af8d1a
Merge branch 'fabric' of github.com:martindale/maki into fabric
martindale Aug 11, 2018
a0506ab
Migrate to @FabricLabs
martindale Aug 11, 2018
dec3256
Remove cruft
martindale Aug 15, 2018
2dff44c
Auto-define resources provided in config
martindale Aug 18, 2018
3e8cf5c
Only change id if unset
martindale Aug 18, 2018
9ee63a2
Update tagline, remove SPDY tests
martindale Aug 18, 2018
e1c12ef
Add `stop()` method for exiting Maki :)
martindale Aug 18, 2018
d9edc74
Improve socket hygiene (close sockets), upgrade coalescent
martindale Aug 18, 2018
14e51ef
Merge branch 'tatami' of github.com:FabricLabs/maki into fabric
martindale Aug 18, 2018
4db636c
Refactor Messenger, migrate to async, ES6 class
martindale Aug 23, 2018
931168b
Switch Travis to Node 8
martindale Aug 23, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- '6'
- '8'
services:
- mongodb
- redis-server
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
Maki
Maki · write once, deploy everywhere.
==============
![Project Status](https://img.shields.io/badge/status-alpha-red.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/martindale/maki.svg?branch=master&style=flat-square)](https://travis-ci.org/martindale/maki)
[![Coverage Status](https://img.shields.io/coveralls/martindale/maki.svg?style=flat-square)](https://coveralls.io/r/martindale/maki)
[![Total Contributors](https://img.shields.io/github/contributors/martindale/maki.svg?style=flat-square)](https://github.com/martindale/maki/contributors)
[![Sustainability](https://img.shields.io/gratipay/team/fabric-foundation.svg?style=flat-square)](https://gratipay.com/Fabric-Foundation)
[![Build Status](https://img.shields.io/travis/FabricLabs/maki.svg?branch=master&style=flat-square)](https://travis-ci.org/FabricLabs/maki)
[![Coverage Status](https://img.shields.io/coveralls/FabricLabs/maki.svg?style=flat-square)](https://coveralls.io/r/FabricLabs/maki)
[![Total Contributors](https://img.shields.io/github/contributors/FabricLabs/maki.svg?style=flat-square)](https://github.com/FabricLabs/maki/contributors)

The complete stack for building extensible apps, faster than ever. Hand-roll your application by telling Maki what your application does, and it takes care of the rest – without getting in your way if you want to customize it.

Expand All @@ -15,7 +14,7 @@ The complete stack for building extensible apps, faster than ever. Hand-roll yo
## Quick Start
You'll need [node.js](http://nodejs.org) to build a Maki application. Additionally, [MongoDB](http://mongodb.org) and [Redis](http://redis.org) are the default storage and messaging engines, so you will need to install and configure them to use the defaults, or override them if you'd like to use something different. We'll be changing this in an upcoming release – see #58 for progress!

1. Install Maki: `npm install martindale/maki`
1. Install Maki: `npm install FabricLabs/maki`
2. Create your app, perhaps in `yourapp.js`:
```javascript
var Maki = require('maki');
Expand Down
2 changes: 1 addition & 1 deletion book.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"plugins": ["exercises", "edit-link", "page-toc"],
"pluginsConfig": {
"edit-link": {
"base": "https://github.com/martindale/maki/edit/community",
"base": "https://github.com/martindale/maki/edit/release-0.3",
"label": "Edit This Page"
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/analytics.jade
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ dom-module#maki-analytics
ga('create', '#{config.analytics.id}', 'auto');
ga('send', 'pageview');
}
})
});
21 changes: 10 additions & 11 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
This is done using the module.exports function,
which sets them when require('./thisfile') is run. */

var NAMESPACE = process.env.MAKI_SERVICE_NAMESPACE || 'maki';
var DATABASE = process.env.MAKI_DATABASE_NAME || NAMESPACE;
const NAMESPACE = process.env.MAKI_SERVICE_NAMESPACE || 'maki';
const DATABASE = process.env.MAKI_DATABASE_NAME || NAMESPACE;

module.exports = {
service: {
name: process.env.MAKI_SERVICE_NAME || 'Maki' ,
source: 'https://github.com/martindale/maki',
source: 'https://github.com/FabricLabs/maki',
// heh. this silly RFC.
authority: process.env.MAKI_SERVICE_AUTHORITY || 'localhost:9200' ,
authority: process.env.MAKI_SERVICE_AUTHORITY || 'localhost:9200',
namespace: NAMESPACE ,
pitch: 'an experimental full-stack framework for cross-platform apps.',
mission: process.env.MAKI_SERVICE_MISSION || 'Maki makes building beautiful apps a breeze.',
description: process.env.MAKI_SERVICE_DESCRIPTION || 'Maki allows you to focus on your project, rather than laboring over architecture decisions. With true isomorphism, you control how your application behaves, and can then customize how your features are exposed on specific platforms.',
about: 'Maki is a noncommercial labor of love, built over many years as an experiment in application design. We find it useful in our daily work, and hope you do, too. <i class="heart icon"></i>',
copyright: 'Maki is copy<em>left</em>, and encourages you to copy, clone, and <em>create</em>. After all, without a rich public domain, how else can we innovate?<br /><br /><a href="https://github.com/martindale/maki/blob/master/LICENSE">Open Source Licenses May Apply</a>',
description: process.env.MAKI_SERVICE_DESCRIPTION || 'From 0 to MVP in 15 minutes. By building your app with Maki, you\'ll have builds for all major platforms right out of the box. Write once, deploy everywhere!',
about: 'We built Maki as a rapid-prototyping tool for <a href="https://fabric.pub">Fabric</a> apps. We\'ve found it fairly useful, so we hope you enjoy. <i class="heart icon"></i>',
copyright: 'We encourage you to copy, clone, and <em>create</em>. After all, without a rich public domain, how else can we innovate? By all means, go forth and <em>build</em>.',
//masthead: '/img/breeze.gif',
cta: {
link: '/examples',
Expand Down Expand Up @@ -58,14 +58,13 @@ module.exports = {
dns: {
name: process.env.MAKI_DNS_NAME || 'localhost'
},
fabric: {
port: 1337
},
services: {
http: {
port: process.env.MAKI_HTTP_PORT || 9200 ,
host: process.env.MAKI_HTTP_HOST || 'localhost'
},
spdy: {
host: process.env.MAKI_HTTP_HOST || 'localhost',
port: process.env.MAKI_SPDY_PORT || 9643
}
},
database: {
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Maki Docs
description: Learn how to use Maki, the a full-stack application framework.
description: Learn how to use Maki, a full-stack application framework.
source: https://github.com/martindale/maki/blob/community/docs/index.md
edit: https://github.com/martindale/maki/edit/community/docs/index.md
---
Expand Down
74 changes: 36 additions & 38 deletions lib/Datastore/index.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,52 @@
var util = require('util');
var mongoose = require('mongoose');
var Grid = require('gridfs-stream')

var Datastore = function(config) {
this._config = config;
this._masters = config.database.masters;
this._slaves = config.database.read;
'use strict';

const EventEmitter = require('events').EventEmitter;
const mongoose = require('mongoose');
const Grid = require('gridfs-stream');

class Datastore extends EventEmitter {
constructor (config) {
super(config);

this._config = Object.assign({
name: config.name,
masters: ['localhost']
}, config);

this._masters = this._config.masters;
this._slaves = this._config.read;

return this;
}
}
util.inherits( Datastore , require('events').EventEmitter );

Datastore.prototype.connectionString = function() {
var config = this._config;
Datastore.prototype.connectionString = function () {
let config = this._config;
if (config.database.string) {
return config.database.string;
} else {
return 'mongodb://' + config.database.masters.join(',') + '/' + config.database.name;
return 'mongodb://' + config.masters.join(',') + '/' + config.name;
}
}

Datastore.prototype.connect = function( done ) {
var self = this;
if (!done) var done = new Function();
};

// we should always create a new connection, as the singleton model
// will get in the way of asynchronous processes, like tests, which
// attempt to close the connection as part of their testing
//self.connection = mongoose.createConnection( self.connectionString() );
//self.connection.on('open', done );
Datastore.prototype.connect = async function connect () {
this.mongoose = await mongoose.connect(this.connectionString());
this.db = mongoose.connection;
this.gfs = Grid(this.db.db, mongoose.mongo);

mongoose.connect( self.connectionString() );
self.mongoose = mongoose; // <- temporary hack
self.db = mongoose.connection;
self.db.on('error', function(err) {
this.db.on('error', function (err) {
console.log('INTERNAL ERROR', err);
});
self.db.once('open', function() {
self.gfs = Grid( self.db.db , mongoose.mongo );

console.log('[DATASTORE]'.bold.green, '[' + self._config.database.name + ']'.bold, 'ready'.green);

self.emit('ready');
return done();
});
console.log('[DATASTORE]'.bold.green, '[' + this._config.database.name + ']'.bold, 'ready'.green);

}
this.emit('ready');
return this;
};

Datastore.prototype.disconnect = function( done ) {
var self = this;
mongoose.disconnect( done );
}
Datastore.prototype.disconnect = async function disconnect (done) {
return mongoose.disconnect(done);
};

/* export a copy of our Datastore */
module.exports = Datastore;
Loading