{"action":"created","comment":{"url":"https://api.github.com/repos/juttle/juttle-engine/pulls/comments/51624645","id":51624645,"diff_hunk":"@@ -1,45 +1,28 @@\n-var Base = require('extendable-base');\n+'use strict';\n var _ = require('underscore');\n var express = require('express');\n var expressWs = require('express-ws');\n-var bodyParser = require('body-parser');\n-var jobs = require('./job-handlers');\n-var paths = require('./path-handlers');\n-var prepares = require('./prepare-handlers');\n var logger = require('log4js').getLogger('juttle-engine');\n \n var read_config = require('juttle/lib/config/read-config');\n var Juttle = require('juttle/lib/runtime').Juttle;\n-var JuttledErrors = require('./errors');\n+var JuttleExpressRoutes = require('./express-routes');\n \n var API_PREFIX = '/api/v0';\n \n-var JuttleEngine = Base.extend({\n+class JuttleEngine {\n \n-    initialize: function(options) {\n-        var config = read_config(options);\n+    constructor(options) {\n+\n+        let config = read_config(options);\n         Juttle.adapters.configure(config.adapters);\n-        var self = this;\n \n-        self._config_path = options.config_path;\n         this._app = express();\n         expressWs(this._app);\n \n         this._app.disable('x-powered-by');\n \n-        this._root_directory = options.root_directory;\n-        this._max_saved_messages = 1024;\n-        this._delayed_job_cleanup = 10000;\n-\n-        if (_.has(config, 'juttled')) {\n-            if (_.has(config.juttled, 'max_saved_messages')) {\n-                this._max_saved_messages = config.juttled.max_saved_messages;\n-            }\n-\n-            if (_.has(config.juttled, 'delayed_job_cleanup')) {\n-                this._delayed_job_cleanup = config.juttled.delayed_job_cleanup;\n-            }\n-        }\n+        JuttleExpressRoutes.add_routes(this._app, options);\n \n         // add cors headers, allow ALL origins\n         this._app.use(function (req, res, next) {","path":"lib/juttle-engine.js","position":52,"original_position":52,"commit_id":"42080b22a20e0e69409ead7f52431471924d58f3","original_commit_id":"42080b22a20e0e69409ead7f52431471924d58f3","user":{"login":"mstemm","id":13422831,"avatar_url":"https://avatars.githubusercontent.com/u/13422831?v=3","gravatar_id":"","url":"https://api.github.com/users/mstemm","html_url":"https://github.com/mstemm","followers_url":"https://api.github.com/users/mstemm/followers","following_url":"https://api.github.com/users/mstemm/following{/other_user}","gists_url":"https://api.github.com/users/mstemm/gists{/gist_id}","starred_url":"https://api.github.com/users/mstemm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstemm/subscriptions","organizations_url":"https://api.github.com/users/mstemm/orgs","repos_url":"https://api.github.com/users/mstemm/repos","events_url":"https://api.github.com/users/mstemm/events{/privacy}","received_events_url":"https://api.github.com/users/mstemm/received_events","type":"User","site_admin":false},"body":"Actually I should probably just take them out now. All the CORS stuff only matters for the workbench app, right?","created_at":"2016-02-02T19:51:44Z","updated_at":"2016-02-02T19:51:44Z","html_url":"https://github.com/juttle/juttle-engine/pull/5#discussion_r51624645","pull_request_url":"https://api.github.com/repos/juttle/juttle-engine/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/juttle/juttle-engine/pulls/comments/51624645"},"html":{"href":"https://github.com/juttle/juttle-engine/pull/5#discussion_r51624645"},"pull_request":{"href":"https://api.github.com/repos/juttle/juttle-engine/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/juttle/juttle-engine/pulls/5","id":57926709,"html_url":"https://github.com/juttle/juttle-engine/pull/5","diff_url":"https://github.com/juttle/juttle-engine/pull/5.diff","patch_url":"https://github.com/juttle/juttle-engine/pull/5.patch","issue_url":"https://api.github.com/repos/juttle/juttle-engine/issues/5","number":5,"state":"open","locked":false,"title":"Add ability to add juttle engine to an express app.","user":{"login":"mstemm","id":13422831,"avatar_url":"https://avatars.githubusercontent.com/u/13422831?v=3","gravatar_id":"","url":"https://api.github.com/users/mstemm","html_url":"https://github.com/mstemm","followers_url":"https://api.github.com/users/mstemm/followers","following_url":"https://api.github.com/users/mstemm/following{/other_user}","gists_url":"https://api.github.com/users/mstemm/gists{/gist_id}","starred_url":"https://api.github.com/users/mstemm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mstemm/subscriptions","organizations_url":"https://api.github.com/users/mstemm/orgs","repos_url":"https://api.github.com/users/mstemm/repos","events_url":"https://api.github.com/users/mstemm/events{/privacy}","received_events_url":"https://api.github.com/users/mstemm/received_events","type":"User","site_admin":false},"body":"Split juttle-engine.js into two pieces. All the express route handlers\r\nare now in express-routes.js. The main function takes an express app\r\nand options and attaches all the routes to the app. We use an express\r\nrouter to hold the middleware (bodyParser), error\r\nhandling (default_error_handler), and all of the http-based routes.\r\n\r\nHowever, the package we use for websocket handling (express-ws)\r\ndoesn't support adding endpoints to routers, only apps. For that\r\nreason, the main function adds to an app instead of returning a\r\nstandalone router.\r\n\r\njuttle-engine.js now just creates the express app, uses express-routes\r\nto add the routes to the app, and starts the server.\r\n\r\nAlso switch to ES6 classes instead of extendable-base.\r\n\r\n@demmer ","created_at":"2016-02-02T01:12:33Z","updated_at":"2016-02-02T19:51:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0f7a2610fca11ec43b5f0600908d0b3f9bb10784","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/juttle/juttle-engine/pulls/5/commits","review_comments_url":"https://api.github.com/repos/juttle/juttle-engine/pulls/5/comments","review_comment_url":"https://api.github.com/repos/juttle/juttle-engine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/juttle/juttle-engine/issues/5/comments","statuses_url":"https://api.github.com/repos/juttle/juttle-engine/statuses/42080b22a20e0e69409ead7f52431471924d58f3","head":{"label":"juttle:express-routes","ref":"express-routes","sha":"42080b22a20e0e69409ead7f52431471924d58f3","user":{"login":"juttle","id":8988633,"avatar_url":"https://avatars.githubusercontent.com/u/8988633?v=3","gravatar_id":"","url":"https://api.github.com/users/juttle","html_url":"https://github.com/juttle","followers_url":"https://api.github.com/users/juttle/followers","following_url":"https://api.github.com/users/juttle/following{/other_user}","gists_url":"https://api.github.com/users/juttle/gists{/gist_id}","starred_url":"https://api.github.com/users/juttle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juttle/subscriptions","organizations_url":"https://api.github.com/users/juttle/orgs","repos_url":"https://api.github.com/users/juttle/repos","events_url":"https://api.github.com/users/juttle/events{/privacy}","received_events_url":"https://api.github.com/users/juttle/received_events","type":"Organization","site_admin":false},"repo":{"id":50863155,"name":"juttle-engine","full_name":"juttle/juttle-engine","owner":{"login":"juttle","id":8988633,"avatar_url":"https://avatars.githubusercontent.com/u/8988633?v=3","gravatar_id":"","url":"https://api.github.com/users/juttle","html_url":"https://github.com/juttle","followers_url":"https://api.github.com/users/juttle/followers","following_url":"https://api.github.com/users/juttle/following{/other_user}","gists_url":"https://api.github.com/users/juttle/gists{/gist_id}","starred_url":"https://api.github.com/users/juttle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juttle/subscriptions","organizations_url":"https://api.github.com/users/juttle/orgs","repos_url":"https://api.github.com/users/juttle/repos","events_url":"https://api.github.com/users/juttle/events{/privacy}","received_events_url":"https://api.github.com/users/juttle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/juttle/juttle-engine","description":"API-based execution engine for juttle programs","fork":false,"url":"https://api.github.com/repos/juttle/juttle-engine","forks_url":"https://api.github.com/repos/juttle/juttle-engine/forks","keys_url":"https://api.github.com/repos/juttle/juttle-engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juttle/juttle-engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juttle/juttle-engine/teams","hooks_url":"https://api.github.com/repos/juttle/juttle-engine/hooks","issue_events_url":"https://api.github.com/repos/juttle/juttle-engine/issues/events{/number}","events_url":"https://api.github.com/repos/juttle/juttle-engine/events","assignees_url":"https://api.github.com/repos/juttle/juttle-engine/assignees{/user}","branches_url":"https://api.github.com/repos/juttle/juttle-engine/branches{/branch}","tags_url":"https://api.github.com/repos/juttle/juttle-engine/tags","blobs_url":"https://api.github.com/repos/juttle/juttle-engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juttle/juttle-engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juttle/juttle-engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/juttle/juttle-engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juttle/juttle-engine/statuses/{sha}","languages_url":"https://api.github.com/repos/juttle/juttle-engine/languages","stargazers_url":"https://api.github.com/repos/juttle/juttle-engine/stargazers","contributors_url":"https://api.github.com/repos/juttle/juttle-engine/contributors","subscribers_url":"https://api.github.com/repos/juttle/juttle-engine/subscribers","subscription_url":"https://api.github.com/repos/juttle/juttle-engine/subscription","commits_url":"https://api.github.com/repos/juttle/juttle-engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/juttle/juttle-engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/juttle/juttle-engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/juttle/juttle-engine/issues/comments{/number}","contents_url":"https://api.github.com/repos/juttle/juttle-engine/contents/{+path}","compare_url":"https://api.github.com/repos/juttle/juttle-engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juttle/juttle-engine/merges","archive_url":"https://api.github.com/repos/juttle/juttle-engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juttle/juttle-engine/downloads","issues_url":"https://api.github.com/repos/juttle/juttle-engine/issues{/number}","pulls_url":"https://api.github.com/repos/juttle/juttle-engine/pulls{/number}","milestones_url":"https://api.github.com/repos/juttle/juttle-engine/milestones{/number}","notifications_url":"https://api.github.com/repos/juttle/juttle-engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juttle/juttle-engine/labels{/name}","releases_url":"https://api.github.com/repos/juttle/juttle-engine/releases{/id}","deployments_url":"https://api.github.com/repos/juttle/juttle-engine/deployments","created_at":"2016-02-01T19:03:14Z","updated_at":"2016-02-01T22:58:34Z","pushed_at":"2016-02-02T19:42:11Z","git_url":"git://github.com/juttle/juttle-engine.git","ssh_url":"git@github.com:juttle/juttle-engine.git","clone_url":"https://github.com/juttle/juttle-engine.git","svn_url":"https://github.com/juttle/juttle-engine","homepage":null,"size":671,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"juttle:master","ref":"master","sha":"1af4f16783736b847e3062805d693fc500c5ba14","user":{"login":"juttle","id":8988633,"avatar_url":"https://avatars.githubusercontent.com/u/8988633?v=3","gravatar_id":"","url":"https://api.github.com/users/juttle","html_url":"https://github.com/juttle","followers_url":"https://api.github.com/users/juttle/followers","following_url":"https://api.github.com/users/juttle/following{/other_user}","gists_url":"https://api.github.com/users/juttle/gists{/gist_id}","starred_url":"https://api.github.com/users/juttle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juttle/subscriptions","organizations_url":"https://api.github.com/users/juttle/orgs","repos_url":"https://api.github.com/users/juttle/repos","events_url":"https://api.github.com/users/juttle/events{/privacy}","received_events_url":"https://api.github.com/users/juttle/received_events","type":"Organization","site_admin":false},"repo":{"id":50863155,"name":"juttle-engine","full_name":"juttle/juttle-engine","owner":{"login":"juttle","id":8988633,"avatar_url":"https://avatars.githubusercontent.com/u/8988633?v=3","gravatar_id":"","url":"https://api.github.com/users/juttle","html_url":"https://github.com/juttle","followers_url":"https://api.github.com/users/juttle/followers","following_url":"https://api.github.com/users/juttle/following{/other_user}","gists_url":"https://api.github.com/users/juttle/gists{/gist_id}","starred_url":"https://api.github.com/users/juttle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juttle/subscriptions","organizations_url":"https://api.github.com/users/juttle/orgs","repos_url":"https://api.github.com/users/juttle/repos","events_url":"https://api.github.com/users/juttle/events{/privacy}","received_events_url":"https://api.github.com/users/juttle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/juttle/juttle-engine","description":"API-based execution engine for juttle programs","fork":false,"url":"https://api.github.com/repos/juttle/juttle-engine","forks_url":"https://api.github.com/repos/juttle/juttle-engine/forks","keys_url":"https://api.github.com/repos/juttle/juttle-engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juttle/juttle-engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juttle/juttle-engine/teams","hooks_url":"https://api.github.com/repos/juttle/juttle-engine/hooks","issue_events_url":"https://api.github.com/repos/juttle/juttle-engine/issues/events{/number}","events_url":"https://api.github.com/repos/juttle/juttle-engine/events","assignees_url":"https://api.github.com/repos/juttle/juttle-engine/assignees{/user}","branches_url":"https://api.github.com/repos/juttle/juttle-engine/branches{/branch}","tags_url":"https://api.github.com/repos/juttle/juttle-engine/tags","blobs_url":"https://api.github.com/repos/juttle/juttle-engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juttle/juttle-engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juttle/juttle-engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/juttle/juttle-engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juttle/juttle-engine/statuses/{sha}","languages_url":"https://api.github.com/repos/juttle/juttle-engine/languages","stargazers_url":"https://api.github.com/repos/juttle/juttle-engine/stargazers","contributors_url":"https://api.github.com/repos/juttle/juttle-engine/contributors","subscribers_url":"https://api.github.com/repos/juttle/juttle-engine/subscribers","subscription_url":"https://api.github.com/repos/juttle/juttle-engine/subscription","commits_url":"https://api.github.com/repos/juttle/juttle-engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/juttle/juttle-engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/juttle/juttle-engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/juttle/juttle-engine/issues/comments{/number}","contents_url":"https://api.github.com/repos/juttle/juttle-engine/contents/{+path}","compare_url":"https://api.github.com/repos/juttle/juttle-engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juttle/juttle-engine/merges","archive_url":"https://api.github.com/repos/juttle/juttle-engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juttle/juttle-engine/downloads","issues_url":"https://api.github.com/repos/juttle/juttle-engine/issues{/number}","pulls_url":"https://api.github.com/repos/juttle/juttle-engine/pulls{/number}","milestones_url":"https://api.github.com/repos/juttle/juttle-engine/milestones{/number}","notifications_url":"https://api.github.com/repos/juttle/juttle-engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juttle/juttle-engine/labels{/name}","releases_url":"https://api.github.com/repos/juttle/juttle-engine/releases{/id}","deployments_url":"https://api.github.com/repos/juttle/juttle-engine/deployments","created_at":"2016-02-01T19:03:14Z","updated_at":"2016-02-01T22:58:34Z","pushed_at":"2016-02-02T19:42:11Z","git_url":"git://github.com/juttle/juttle-engine.git","ssh_url":"git@github.com:juttle/juttle-engine.git","clone_url":"https://github.com/juttle/juttle-engine.git","svn_url":"https://github.com/juttle/juttle-engine","homepage":null,"size":671,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/juttle/juttle-engine/pulls/5"},"html":{"href":"https://github.com/juttle/juttle-engine/pull/5"},"issue":{"href":"https://api.github.com/repos/juttle/juttle-engine/issues/5"},"comments":{"href":"https://api.github.com/repos/juttle/juttle-engine/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/juttle/juttle-engine/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/juttle/juttle-engine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/juttle/juttle-engine/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/juttle/juttle-engine/statuses/42080b22a20e0e69409ead7f52431471924d58f3"}}}}