Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2c3b7d7
created file for schema and added basic fields
Jun 2, 2015
0123366
renamed file and folder
Jun 2, 2015
f8f3d15
files for different schemas
Jun 2, 2015
cc2e859
deleted files, created one for schema collection
Jun 3, 2015
ebb4412
added basic variables for a schema
Jun 3, 2015
4c31ab2
Merge remote-tracking branch 'origin/develop' into feature/form-confi…
Jun 3, 2015
387bc13
added a basic route page with autoform generated schema
Jun 3, 2015
71bbe0a
template with autoform embedded added
Jun 4, 2015
8aed8f6
more variables to the schema
Jun 4, 2015
9e620ed
added couple new variables to the schema
Jun 4, 2015
3b610da
changed quickForm to autoForm, added some styling
Jun 4, 2015
630e769
show form elements inline first attempt
Jun 4, 2015
5fdeea5
back to two lines view
Jun 5, 2015
f2f010e
changed schema from coffee to js
Jun 8, 2015
5496830
added more fields
Jun 8, 2015
b4495a9
more variables added
Jun 10, 2015
1685d5c
more variables
Jun 10, 2015
a5ede2c
Merge remote-tracking branch 'origin/develop' into feature/form-confi…
Jun 10, 2015
cccd18e
api-umbrella package updated
Jun 10, 2015
4957107
change schema's name
Jun 10, 2015
6f63b99
new variables, afquickfields
Jun 10, 2015
34f49d6
basic example getting apibackends from apiumbrella
Jun 10, 2015
898b570
added config.json to .gitignore
Jun 12, 2015
9a04225
changed title
Jun 12, 2015
34c4cca
added label
Jun 12, 2015
0bae7b4
added missing variables, optional fields
Jun 12, 2015
242c61c
show api backends form on admin dashboard menu
Jun 12, 2015
fa9fc81
method for sync
Jun 12, 2015
761db3b
cleaned comments
Jun 12, 2015
ba4ccfe
sync method added to syncedcron
Jun 12, 2015
d6af71d
conflicts solved
Jun 14, 2015
7114292
Merge branch 'develop' into feature/form-configure-API
Jun 14, 2015
20726cd
Merge branch 'develop' into feature/form-configure-API
frenchbread Jun 15, 2015
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
1 change: 0 additions & 1 deletion .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ boilerplate-generator@1.0.3
bootstrap@0.3.1
bruz:github-api@0.2.4_1
brylie:api-umbrella@0.2.4
brylie:api-umbrella@0.2.3
callback-hook@1.0.3
cfs:access-point@0.1.49
cfs:base-package@0.0.30
Expand Down
1 change: 1 addition & 0 deletions client/subscriptions.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Meteor.subscribe('apiUmbrellaUsers');
Meteor.subscribe('apiBackends');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to reconsider these subscriptions, as they publish all data to all clients.

42 changes: 42 additions & 0 deletions client/views/api_backends/api_backends.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<template name="apiBackends">
<div class="row">
<div class="col-lg-6 col-lg-offset-3">
{{#autoForm collection="ApiBackends" doc=this id="apiBackends"}}
{{> afQuickField name='name'}}
<h4>Host</h4>
<hr />
<div class="row">
<div class="col-lg-3">
{{> afQuickField name='backend_protocol' options="allowed"}}
</div>
<div class="col-lg-6">
{{> afQuickField name='backend_host'}}
</div>
<div class="col-lg-3">
{{> afQuickField name='backend_port'}}
</div>
</div>
{{> afQuickField name='server'}}
<!-- TODO: show fields inline
<form>
<div class="form-inline">
{{> afQuickField name='matching'}}
</div>
</form>
-->
{{> afQuickField name='matching'}}
<h4>Global Request Settings</h4>
{{> afQuickField name='append_query_string'}}
{{> afQuickField name='set_headers'}}
{{> afQuickField name='http_basic_auth'}}
{{> afQuickField name='require_https' options="allowed"}}
{{> afQuickField name='api_key_verification_level' options="allowed"}}
{{> afQuickField name='required_roles' options="allowed"}}
<h5>Pass API Key to Backend (deprecated)</h5>
{{> afQuickField name='pass_api_key_header'}}
{{> afQuickField name='pass_api_key_query_param'}}
{{> afQuickField name='rate_limit_mode' options="allowed"}}
{{/autoForm}}
</div>
</div>
</template>
269 changes: 269 additions & 0 deletions collections/backend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
ApiBackends = new Mongo.Collection('apiBackends');

ApiBackendsSchema = new SimpleSchema({
id: {
type: String,
optional: true
},
name: {
type: String,
optional: true
},
sort_order: {
type: Number,
optional: true
},
backend_protocol: {
type: String,
optional: true,
allowedValues: [
'http',
'https'
],
label: 'Backend protocol'
},
backend_host: {
type: String,
optional: true
},
backend_port: {
type: Number,
optional: true
},
frontend_host: {
type: String,
optional: true
},
balance_algorithm: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any pre-defined strings for the balance algorithm? E.g. 'round-robin'.

type: String,
optional: true
},
server: {
type: [Object],
optional: true,
label: 'Host'
},
"server.$.backend_host": {
type: String,
optional: true
},
"server.$.backend_port": {
type: String,
optional: true,
regEx: /^[0-9]{2,5}$/
},
matching: {
type: [Object],
optional: true,
},
"matching.$.frontend_prefix": {
label: 'Frontend Prefix',
optional: true,
type: String
},
"matching.$.backend_prefix": {
label: 'Backend Prefix',
optional: true,
type: String,
regEx: /^[a-z0-9A-Z_]{3,15}$/
},
duration: {
type: Number,
optional: true,
label: 'Duration'
},
accuracy:{
type: Number,
optional: true
},
limit_by: {
type: String,
optional: true
},
limit: {
type: Number,
optional: true
},
distributed: {
type: Boolean,
optional: true
},
response_headers: {
type: Boolean,
optional: true
},
matcher_type: {
type: String,
optional: true
},
http_method: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Label may be needed here, as HTTP is all uppercase.

type: String,
optional: true
},
frontend_matcher: {
type: String,
optional: true
},
backend_replacement: {
type: String,
optional: true
},
matcher: {
type: String,
optional: true
},
http_method: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Label may be needed here, as HTTP is all uppercase.

type: String,
optional: true
},
from: {
type: String,
optional: true
},
to: {
type: String,
optional: true
},
set_headers: {
type: String,
optional: true,
min: 20,
max: 1000,
autoform: {
rows: 2
},
label: 'Set Headers'
},
append_query_string: {
type: String,
optional: true,
label: 'Append Query String Parameters'
},
http_basic_auth: {
type: String,
optional: true,
label: 'HTTP Basic Authentication'
},
require_https: {
type: String,
optional: true,
allowedValues: [
'Inherit (default - optional)',
'Optional - HTTPS is optional',
'Required - HTTPS is mandatory'
],
label: 'HTTPS Requirements'
},
require_https_transition_start_at: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Label may be needed here, as HTTPS is all uppercase.

type: Date,
optional: true
},
disable_api_key: {
type: Boolean,
optional: true
},
api_key_verification_level: {
type: String,
optional: true,
allowedValues: [
'Inherit (default - required)',
'Required - API keys are mandatory',
'Disabled - API keys are optional'
],
label: 'API Key Checks'
},
api_key_verification_transition_start_at: {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Label needed.

type: Date,
optional: true
},
required_roles: {
type: Array,
minCount: 1,
maxCount: 3,
optional: true,
label: 'Required Roles',
autoform: {
options: [
{
label: 'api-umbrella-contact-form',
value: 'api-umbrella-contact-form'
},
{
label: 'api-umbrella-key-creator',
value: 'api-umbrella-key-creator'
},
{
label: 'write_access',
value: 'write_access'
}
]
}
},
"required_roles.$": {
type: String,
optional: true
},
rate_limit_mode: {
type: String,
optional: true,
allowedValues: [
'Default rate limits',
'Custom rate limits',
'Unlimited requests'
],
label: 'Rate limit'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent capitalization of first letters. Choose a method for the schema and use it consistently.

},
anonymous_rate_limit_behavior: {
type: String,
optional: true
},
authenticated_rate_limit_behavior: {
type: String,
optional: true
},
pass_api_key_header: {
type: Boolean,
optional: true,
defaultValue: false,
label: 'Via HTTP header'
},
pass_api_key_query_param: {
type: Boolean,
optional: true,
defaultValue: false,
label: 'Via GET query parameter'
},
error_templates: {
// type: [Object]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup needed.

type: String,
optional: true
},
error_data: {
// type: [Object]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup.

type: String,
optional: true
},
created_at: {
type: Date,
optional: true
},
created_by: {
type: String,
optional: true
},
updated_at: {
type: Date,
optional: true
},
updated_by: {
type: String,
optional: true
},
version: {
type: Number,
optional: true
}
});

ApiBackends.attachSchema(ApiBackendsSchema);

14 changes: 11 additions & 3 deletions lib/_config/adminConfig.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
{label: 'Last Name',name:'last_name'}
]
}
ApiBackends: {
color: 'blue'
icon: 'gear'
tableColumns: [
{label: 'Name', name: 'name'}
{label: 'Backend Host', name: 'backend_host'}
]
}
ApiUmbrellaAdmins: {
color: 'blue'
icon: 'user-md'
Expand All @@ -32,9 +40,9 @@
icon: 'comments'
auxCollections: ['Posts']
tableColumns: [
{label: 'Content';name:'content'}
{label:'Post';name:'doc',collection: 'Posts',collection_property:'title'}
{label:'User',name:'owner',collection:'Users'}
{label: 'Content', name:'content'}
{label:'Post', name:'doc',collection: 'Posts',collection_property:'title'}
{label:'User', name:'owner',collection:'Users'}
]
}
dashboard:
Expand Down
4 changes: 4 additions & 0 deletions lib/router/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Router.map ->
path: "/"
layoutTemplate: "homeLayout"

@route "apiBackends",
path: "/apibackends"
layoutTemplate: "homeLayout"

@route "dashboard",
path: "/dashboard"
waitOn: ->
Expand Down
20 changes: 20 additions & 0 deletions server/methods/apiBackends.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Meteor.methods({
"syncApiBackends":function () {
// Check if API Umbrella settings are available
if (Meteor.settings.api_umbrella) {
// Get API Backends from API Umbrella instance
var response = apiUmbrellaWeb.adminApi.v1.apiBackends.getApiBackends();
var apiBackends = response.data.data;

_.each(apiBackends, function (item) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming 'item' to 'backend' in order to be more explicit.

// Get existing API Backend
var existingApiBackend = ApiBackends.findOne({'id': item.id});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If using 'backend' instead of 'item', replace 'item.id' with 'backend.id'. This will improve readability.


// If API Backend doesn't exist in collection, insert into collection
if (! existingApiBackend ) {
ApiBackends.insert(item);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If using 'backend' instead of 'item', replace 'item' with 'backend' here.

};
});
};
}
});
3 changes: 3 additions & 0 deletions server/publish/apiBackends.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Meteor.publish('apiBackends', function () {
return ApiBackends.find();
});
Loading