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

Plugins #760

Closed
wants to merge 89 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
9f8b98d
Added package.json for plugin_router.
mlucy Aug 11, 2016
98e828a
Added index.js to plugin_router.
mlucy Aug 12, 2016
8b3bcac
Added package.json for permissions plugin.
mlucy Aug 12, 2016
e1e13c6
checkpoint
mlucy Aug 12, 2016
f123d52
checkpoint
mlucy Aug 13, 2016
8cfac85
Reworked reliable stuff.
mlucy Aug 15, 2016
1378c09
added ReliableMetadata sketch
Aug 16, 2016
bd146d1
Added reliable shit.
mlucy Aug 16, 2016
2143e8c
style fixes
mlucy Aug 16, 2016
9dc76cf
merged
mlucy Aug 16, 2016
a35437d
style fixes
mlucy Aug 16, 2016
365896f
checkpoint
mlucy Aug 16, 2016
58cc7f3
fixed syntax
Aug 16, 2016
b10f02c
working on middleware execution
Aug 16, 2016
2651ec1
it build!
mlucy Aug 17, 2016
25b91b6
checkpoint
mlucy Aug 17, 2016
c9136c7
checkpoint
mlucy Aug 17, 2016
9425197
fixing test bugs
Aug 17, 2016
7fdb2f2
fixed more test problems
Aug 17, 2016
757fc07
fixed eslint problems
Aug 17, 2016
ea26fec
wrote broken graph code
mlucy Aug 18, 2016
1432a9e
fixed eslint errors in plugin router
Aug 18, 2016
7df9136
checkpoint
Aug 18, 2016
5748188
checkpoint
Aug 19, 2016
5094ea8
checkpoint
mlucy Aug 20, 2016
e4b93bc
fixed square brackets style
mlucy Aug 23, 2016
54ba00a
checkpoint
mlucy Aug 24, 2016
359039a
theoretically working
mlucy Aug 25, 2016
13d6109
moved logic from server to permissions plugin
Aug 25, 2016
75f96a9
moving horizon.js to index.js
Aug 25, 2016
9ef28ae
checkpoint
Aug 25, 2016
4bf76e8
camelcase changes
Aug 25, 2016
0c9f57a
checkpoint
Aug 25, 2016
b8d4a08
checkpoint
Aug 25, 2016
8a50370
cleanup of obsolete code
Aug 25, 2016
b370128
fixed server
Aug 25, 2016
82d20df
Everything works
Aug 25, 2016
c62e3e0
everything works a little more
Aug 26, 2016
386a8e3
getting stuff running
Aug 30, 2016
75cc00a
plugins almost working
Aug 31, 2016
bc7bdee
checkpoint
Aug 31, 2016
128aa95
checkpoint
Aug 31, 2016
77f3db8
working on stuff
mlucy Aug 31, 2016
7f7b975
collection broken
mlucy Sep 1, 2016
c99fd73
added stuff
mlucy Sep 1, 2016
102fdc0
fixing bugs in testing
Sep 1, 2016
b281558
reworking plugin dependencies
Sep 2, 2016
06c79d0
restructuring plugins module
Sep 2, 2016
7ce2cea
more plugins module resturcturing
Sep 2, 2016
032554a
more plugin reorganization
Sep 2, 2016
027d064
fixing eslint errors in plugins
Sep 2, 2016
26613f4
working on getting the test server running again
Sep 2, 2016
f948716
fixing es6 compat
Sep 2, 2016
12846c2
broke plugins up into separate modules
Sep 2, 2016
9cb6e71
reorganizing some plugin stuff
Sep 2, 2016
9cf5acd
added module for default plugins
Sep 2, 2016
dead3b0
working on getting dev environment easy to set up
Sep 2, 2016
7eab310
fixed up setupDev.sh to provision plugins
Sep 2, 2016
a78b0db
fixing bugs
Sep 2, 2016
1615b7a
fixed incorrect error handling in collection creation
Sep 2, 2016
43c921a
about to fix namespaces
mlucy Sep 3, 2016
f5a8415
fixed namespacing
mlucy Sep 3, 2016
a1dfb87
fixing bugs
Sep 5, 2016
16575ca
about to start moving and writing tests
Sep 5, 2016
0a26b50
stuffs
mlucy Sep 5, 2016
4a33c83
Merge branch 'next' into grey_plugins
Sep 5, 2016
2da2dc1
Merge branch 'plugins' into grey_plugins
Sep 5, 2016
7845099
migrated permissions template tests
Sep 5, 2016
ec572f1
adding source-map-support devDependency to plugins
Sep 5, 2016
3f42c9d
migrating server tests to integration tests
Sep 5, 2016
d6b196a
fix a few test bugs
Sep 7, 2016
9b1e023
added 5 sec wait for metadata to sync
Sep 7, 2016
b14fa0d
got protocol tests passing
Sep 8, 2016
03673ca
fixed collections and permissions readiness
Sep 8, 2016
890070f
fixed test create_collection
Sep 8, 2016
b4f7882
fixed some tests
Sep 8, 2016
750b95e
reworking plugin-router, added stubs for differend backend implementa…
Sep 8, 2016
02cfdb9
no longer pass server to plugins, but a curated plugin context
Sep 9, 2016
6fda005
got previously working tests working again
Sep 9, 2016
8079784
fixing problems in integration tests
Sep 9, 2016
9361715
fixed cleanup, removed old console log statements
Sep 9, 2016
06d1427
fixed some tests
Sep 9, 2016
0392e90
almost have all server tests running
Sep 10, 2016
f61425c
changed how user info is passed to validators
Sep 11, 2016
bddb240
fixed all server tests
Sep 11, 2016
dc9ef13
got test server running
Sep 11, 2016
328d124
checkpoint
Sep 13, 2016
da538ed
camelCasing and fixing tests
Sep 13, 2016
203b420
checkpoint
Sep 16, 2016
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
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
extends: "eslint:recommended",
rules: {
"arrow-body-style": [ERROR, "as-needed"],
"array-bracket-spacing": [ ERROR, "always" ],
"array-bracket-spacing": [ ERROR, "never" ],
"arrow-parens": [ ERROR, "always" ],
"arrow-spacing": [ ERROR ],
"block-spacing": [ ERROR, "always" ],
Expand Down Expand Up @@ -68,7 +68,7 @@ module.exports = {
"no-var": [ ERROR ],
"no-void": [ ERROR ],
"no-with": [ ERROR ],
"object-curly-spacing": [ ERROR, "always" ],
"object-curly-spacing": [ ERROR, "never" ],
"one-var": [ ERROR, { "uninitialized": "always", "initialized": "never" } ],
"operator-assignment": [ ERROR, "always" ],
"operator-linebreak": [ ERROR, "after" ],
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
client/dist/
client/lib/
rethinkdb_data_test
rethinkdb_data/
Expand All @@ -11,3 +10,10 @@ node_modules/
.hz/
config.toml
**/.vscode
**/.*.swp

**/dist/

# RethinkDB stuff
**/rethinkdb_data/
**/rethinkdb_data_test/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN apt update && apt install -y git

COPY . /usr/horizon/
WORKDIR /usr/horizon
RUN cd test; ./setupDev.sh
RUN ./setupDev.sh

EXPOSE 8181

Expand Down
10 changes: 10 additions & 0 deletions babelify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

dirs="server plugins plugin-router plugin-utils test"
for path in `find $dirs -name .babelrc | grep -v node_modules`; do
{
babel ${path%%.babelrc}src -d ${path%%.babelrc}dist -s true -w
} &
done

wait
8 changes: 4 additions & 4 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "horizon",
"version": "2.0.0",
"version": "3.0.0-alpha-0",
"description": "An open-source developer platform for building realtime, scalable web apps.",
"main": "src/main.js",
"repository": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/rethinkdb/horizon#readme",
"dependencies": {
"@horizon/server": "2.0.0",
"@horizon/server": "3.0.0-alpha-0",
"argparse": "^1.0.3",
"bluebird": "^3.4.1",
"chalk": "^1.1.3",
Expand All @@ -37,9 +37,9 @@
},
"devDependencies": {
"chai": "^3.5.0",
"eslint": "^2.3.0",
"eslint": "^3.1.0",
"istanbul": "^0.4.3",
"mocha": "2.4.5",
"mocha": "^2.5.3",
"mock-fs": "^3.10.0",
"sinon": "1.17.3",
"strip-ansi": "^3.0.1",
Expand Down
6 changes: 3 additions & 3 deletions cli/src/create-cert.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const run = (args) => {
};

// generate the arguments to the command
const binArgs = [ 'req', '-x509', '-nodes', '-batch',
const binArgs = ['req', '-x509', '-nodes', '-batch',
'-newkey', `${settings.algo}:${settings.bits}`,
'-keyout', settings.keyOutName,
'-out', settings.certOutName,
Expand All @@ -39,8 +39,8 @@ const run = (args) => {
const sslProc = spawn(settings.binaryName, binArgs);

// pipe output appropriately
sslProc.stdout.pipe(process.stdout, { end: false });
sslProc.stderr.pipe(process.stderr, { end: false });
sslProc.stdout.pipe(process.stdout, {end: false});
sslProc.stderr.pipe(process.stderr, {end: false});

// say nice things to the user when it's done
sslProc.on('error', reject);
Expand Down
6 changes: 3 additions & 3 deletions cli/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ rethinkdb_data
`;

const parseArguments = (args) => {
const parser = new argparse.ArgumentParser({ prog: 'hz init' });
parser.addArgument([ 'projectName' ],
{ action: 'store',
const parser = new argparse.ArgumentParser({prog: 'hz init'});
parser.addArgument(['projectName'],
{action: 'store',
help: 'Name of directory to create. Defaults to current directory',
nargs: '?',
}
Expand Down
24 changes: 10 additions & 14 deletions cli/src/make-token.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
'use strict';

const interrupt = require('./utils/interrupt');
const config = require('./utils/config');
const horizon_server = require('@horizon/server');

const path = require('path');
const jwt = require('jsonwebtoken');

const r = horizon_server.r;
const logger = horizon_server.logger;
const argparse = require('argparse');

const parseArguments = (args) => {
const parser = new argparse.ArgumentParser({ prog: 'hz make-token' });
const parser = new argparse.ArgumentParser({prog: 'hz make-token'});

parser.addArgument(
[ '--token-secret' ],
{ type: 'string', metavar: 'SECRET',
help: 'Secret key for signing the token.' });
['--token-secret'],
{type: 'string', metavar: 'SECRET',
help: 'Secret key for signing the token.'});

parser.addArgument(
[ 'user' ],
{ type: 'string', metavar: 'USER_ID',
help: 'The ID of the user to issue a token for.' });
['user'],
{type: 'string', metavar: 'USER_ID',
help: 'The ID of the user to issue a token for.'});

return parser.parseArgs(args);
};
Expand All @@ -43,7 +39,7 @@ const processConfig = (parsed) => {
options.project_name = path.basename(path.resolve(options.project_path));
}

return Object.assign(options, { user: parsed.user });
return Object.assign(options, {user: parsed.user});
};

const run = (args) => Promise.resolve().then(() => {
Expand All @@ -53,9 +49,9 @@ const run = (args) => Promise.resolve().then(() => {
throw new Error('No token secret specified, unable to sign the token.');
}
const token = jwt.sign(
{ id: options.user, provider: null },
{id: options.user, provider: null},
new Buffer(options.token_secret, 'base64'),
{ expiresIn: '1d', algorithm: 'HS512' }
{expiresIn: '1d', algorithm: 'HS512'}
);
console.log(`${token}`);
});
Expand Down
62 changes: 29 additions & 33 deletions cli/src/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const parse_yes_no_option = require('./utils/parse_yes_no_option');
const start_rdb_server = require('./utils/start_rdb_server');
const NiceError = require('./utils/nice_error.js');

const VERSION_2_0 = [ 2, 0, 0 ];
const VERSION_2_0 = [2, 0, 0];

function run(cmdArgs) {
const options = processConfig(cmdArgs);
interrupt.on_interrupt(() => teardown());
return Promise.resolve().bind({ options })
return Promise.resolve().bind({options})
.then(setup)
.then(validateMigration)
.then(makeBackup)
Expand All @@ -45,45 +45,45 @@ function white() {

function processConfig(cmdArgs) {
// do boilerplate to get config args :/
const parser = new argparse.ArgumentParser({ prog: 'hz migrate' });
const parser = new argparse.ArgumentParser({prog: 'hz migrate'});

parser.addArgument([ 'project_path' ], {
parser.addArgument(['project_path'], {
default: '.',
nargs: '?',
help: 'Change to this directory before migrating',
});

parser.addArgument([ '--project-name', '-n' ], {
parser.addArgument(['--project-name', '-n'], {
help: 'Name of the Horizon project server',
});

parser.addArgument([ '--connect', '-c' ], {
parser.addArgument(['--connect', '-c'], {
metavar: 'host:port',
default: undefined,
help: 'Host and port of the RethinkDB server to connect to.',
});

parser.addArgument([ '--rdb-user' ], {
parser.addArgument(['--rdb-user'], {
default: 'admin',
metavar: 'USER',
help: 'RethinkDB User',
});

parser.addArgument([ '--rdb-password' ], {
parser.addArgument(['--rdb-password'], {
default: undefined,
metavar: 'PASSWORD',
help: 'RethinkDB Password',
});

parser.addArgument([ '--start-rethinkdb' ], {
parser.addArgument(['--start-rethinkdb'], {
metavar: 'yes|no',
default: 'yes',
constant: 'yes',
nargs: '?',
help: 'Start up a RethinkDB server in the current directory',
});

parser.addArgument([ '--skip-backup' ], {
parser.addArgument(['--skip-backup'], {
metavar: 'yes|no',
default: 'no',
constant: 'yes',
Expand All @@ -92,7 +92,7 @@ function processConfig(cmdArgs) {
' before migrating',
});

parser.addArgument([ '--nonportable-backup' ], {
parser.addArgument(['--nonportable-backup'], {
metavar: 'yes|no',
default: 'no',
constant: 'yes',
Expand Down Expand Up @@ -149,7 +149,7 @@ function setup() {
// start rethinkdb server if necessary
if (this.options.start_rethinkdb) {
green(' ├── Starting RethinkDB server');
return start_rdb_server({ quiet: true }).then((server) => {
return start_rdb_server({quiet: true}).then((server) => {
this.rdb_server = server;
this.options.rdb_host = 'localhost';
this.options.rdb_port = server.driver_port;
Expand Down Expand Up @@ -193,15 +193,15 @@ function validateMigration() {
const tablesHaveHzPrefix = `Some tables in ${project} have an hz_ prefix`;
const checkForHzTables = r.db('rethinkdb')
.table('table_config')
.filter({ db: project })('name')
.filter({db: project})('name')
.contains((x) => x.match('^hz_'))
.branch(r.error(tablesHaveHzPrefix), true);
const waitForCollections = r.db(`${project}_internal`)
.table('collections')
.wait({ timeout: 30 })
.wait({timeout: 30})
.do(() => r.db(project).tableList())
.forEach((tableName) =>
r.db(project).table(tableName).wait({ timeout: 30 })
r.db(project).table(tableName).wait({timeout: 30})
);

return Promise.resolve().then(() => {
Expand Down Expand Up @@ -292,11 +292,11 @@ function renameUserTables() {
const project = this.options.project_name;
return Promise.resolve().then(() => {
white('Removing suffix from user tables');
return r.db(`${project}_internal`).wait({ timeout: 30 }).
return r.db(`${project}_internal`).wait({timeout: 30}).
do(() => r.db(`${project}_internal`).table('collections')
.forEach((collDoc) => r.db('rethinkdb').table('table_config')
.filter({ db: project, name: collDoc('table') })
.update({ name: collDoc('id') }))
.filter({db: project, name: collDoc('table')})
.update({name: collDoc('id')}))
).run(this.conn)
.then(() => green(' └── Suffixes removed'));
});
Expand All @@ -310,7 +310,7 @@ function moveInternalTables() {
return Promise.resolve().then(() => {
white(`Moving internal tables from ${project}_internal to ${project}`);
return r.db('rethinkdb').table('table_config')
.filter({ db: `${project}_internal` })
.filter({db: `${project}_internal`})
.update((table) => ({
db: project,
name: r.branch(
Expand All @@ -336,19 +336,17 @@ function renameIndices() {
white('Renaming indices to new JSON format');
return r.db(project).tableList().forEach((tableName) =>
r.db(project).table(tableName).indexList().forEach((indexName) =>
r.db(project).table(tableName)
.indexRename(indexName, rename(indexName))
r.db(project).table(tableName).indexRename(indexName, rename(indexName))
)
).run(this.conn)
.then(() => green(' └── Indices renamed.'));
).run(this.conn).then(() => green(' └── Indices renamed.'));
});

function rename(name) {
// ReQL to rename the index name to the new format
const initialState = {
escaped: false,
field: '',
fields: [ ],
fields: [],
};
return name.split('')
.fold(initialState, (acc, c) =>
Expand All @@ -359,22 +357,20 @@ function renameIndices() {
field: acc('field').add(c),
}),
c.eq('\\'),
acc.merge({ escaped: true }),
acc.merge({escaped: true}),
c.eq('_'),
acc.merge({
fields: acc('fields').append(acc('field')),
field: '',
}),
acc.merge({ field: acc('field').add(c) })
acc.merge({field: acc('field').add(c)})
)
).do((state) =>
// last field needs to be appended to running list
state('fields').append(state('field'))
// wrap each field in an array
.map((field) => [ field ])
)
.toJSON()
.do((x) => r('hz_').add(x));
.map((field) => [field])
).toJSON().do((x) => r('hz_').add(x));
}
}

Expand All @@ -385,15 +381,15 @@ function rewriteHzCollectionDocs() {
return Promise.resolve().then(() => {
white('Rewriting hz_collections to new format');
return r.db(project).table('hz_collections')
.update({ table: r.literal() })
.update({table: r.literal()})
.run(this.conn);
}).then(() => green(' ├── "table" field removed'))
.then(() => r.db(project).table('hz_collections')
.insert({ id: 'users' })
.insert({id: 'users'})
.run(this.conn))
.then(() => green(' ├── Added document for "users" table'))
.then(() => r.db(project).table('hz_collections')
.insert({ id: 'hz_metadata', version: VERSION_2_0 })
.insert({id: 'hz_metadata', version: VERSION_2_0})
.run(this.conn))
.then(() => green(' └── Adding the metadata document with schema version:' +
`${JSON.stringify(VERSION_2_0)}`));
Expand Down
Loading