Skip to content

Commit

Permalink
Restructured project
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocean15 committed Jan 25, 2018
1 parent 8d7a91f commit 54d7712
Show file tree
Hide file tree
Showing 56 changed files with 2,154 additions and 221 deletions.
9 changes: 8 additions & 1 deletion .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ [email protected] # Enable ECMAScript2015+ syntax in app code
[email protected] # Server-side component of the `meteor shell` command

planettraining:material-design-icons-font
react-meteor-data
nimble:restivus
accounts-password
alanning:roles
mdg:validated-method
ddp-rate-limiter
universe:i18n
react-meteor-data
aldeed:collection2-core
aldeed:schema-deny
session
less
126 changes: 0 additions & 126 deletions client/main.css

This file was deleted.

2 changes: 1 addition & 1 deletion client/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
</head>

<body>
<div id="render-target"></div>
<div id="app"></div>
</body>
6 changes: 2 additions & 4 deletions client/main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from 'react';
import { Meteor } from 'meteor/meteor';
import { render } from 'react-dom';

import App from '../imports/ui/App.js';
import { renderRoutes } from '../imports/startup/client/routes.js';

Meteor.startup(() => {
render(<App />, document.getElementById('render-target'));
render(renderRoutes(), document.getElementById('app'));
});
20 changes: 20 additions & 0 deletions client/main.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@import "{}/imports/ui/stylesheets/reset.less";

// Global namespace
@import "{}/imports/ui/stylesheets/base.less";
@import '{}/imports/ui/stylesheets/button.less';
@import '{}/imports/ui/stylesheets/form.less';
@import '{}/imports/ui/stylesheets/link.less';
@import '{}/imports/ui/stylesheets/nav.less';
@import '{}/imports/ui/stylesheets/fade-transition.less';

// App layout
@import "{}/imports/ui/layouts/App.less";

// Pages
@import "{}/imports/ui/pages/NotFoundPage.less";

// Components
@import "{}/imports/ui/components/ConnectionNotification.less";
@import "{}/imports/ui/components/Loading.less";
@import "{}/imports/ui/components/Message.less";
20 changes: 20 additions & 0 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"components": {
"connectionNotification": {
"tryingToConnect": "Trying to connect",
"connectionIssue": "There seems to be a connection issue"
}
},
"pages": {
"notFoundPage": {
"pageNotFound": "Page not found"
}
},
"api": {
"recipients": {
"insert": {
"accessDenied": "Cannot add recipients without permissions"
}
}
}
}
28 changes: 0 additions & 28 deletions imports/api/recipients.js

This file was deleted.

44 changes: 44 additions & 0 deletions imports/api/recipients/methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Meteor } from 'meteor/meteor';
import { _ } from 'meteor/underscore';
import { ValidatedMethod } from 'meteor/mdg:validated-method';
import SimpleSchema from 'simpl-schema';
import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
import { Roles } from 'meteor/alanning:roles';

import { Recipients } from './recipients.js';

export const insert = new ValidatedMethod({
name: 'recipients.insert',
validate: Recipients.simpleSchema().pick(['email', 'customerId']).validator({ clean: true, filter: false }),
run({ email, customerId }) {
if(!this.userId || !Roles.userIsInRole(this.userId, ['admin'])) {
throw new Meteor.Error('recipients.insert.accessDenied',
'Cannot add recipients without permissions');
}
// TODO: Private+PublicKey
const recipient = {
email,
customerId,
createdAt: new Date(),
};

Recipients.insert(todo);
},
});

// Get list of all method names on Recipients
const RECIPIENTS_METHODS = _.pluck([
insert
], 'name');

if (Meteor.isServer) {
// Only allow 5 recipient operations per connection per second
DDPRateLimiter.addRule({
name(name) {
return _.contains(RECIPIENTS_METHODS, name);
},

// Rate limit per connection ID
connectionId() { return true; },
}, 5, 1000);
}
68 changes: 68 additions & 0 deletions imports/api/recipients/recipients.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';

class RecipientsCollection extends Mongo.Collection {
insert(recipient, callback) {
const ourRecipient = recipient;
ourRecipient.createdAt = ourRecipient.createdAt || new Date();
const result = super.insert(ourRecipient, callback);
return result;
}
update(selector, modifier) {
const result = super.update(selector, modifier);
return result;
}
remove(selector) {
const result = super.remove(selector);
return result;
}
}

export const Recipients = new RecipientsCollection('recipients');

// Deny all client-side updates since we will be using methods to manage this collection
Recipients.deny({
insert() { return true; },
update() { return true; },
remove() { return true; },
});

Recipients.schema = new SimpleSchema({
_id: {
type: String,
regEx: SimpleSchema.RegEx.Id,
},
email: {
type: String,
denyUpdate: true,
},
customerId: {
type: String,
denyUpdate: false,
},
privateKey: {
type: String,
max: 100,
denyUpdate: true,
},
publicKey: {
type: String,
max: 100,
denyUpdate: true,
},
createdAt: {
type: Date,
denyUpdate: true,
}
});

Recipients.attachSchema(Recipients.schema);

// This represents the keys from Recipient objects that should be published
// to the client. If we add secret properties to Recipient objects, don't list
// them here to keep them private to the server.
Recipients.publicFields = {
customerId: 1,
publicKey: 1,
createdAt: 1
};
Loading

0 comments on commit 54d7712

Please sign in to comment.