Skip to content

Instantly share code, notes, and snippets.

View varavut's full-sized avatar

Varavut Lormongkol varavut

View GitHub Profile
if (Meteor.isClient) {
Samples = new Mongo.Collection('samples');
}
if (Meteor.isClient) {
Samples = new Mongo.Collection('samples');
Template.hello.onCreated(function () {
var self = this;
self.autorun(function () {
self.subscribe('REST2DDP', 'sample');
});
});
<head>
<title>meteor-rest2ddp</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
<ul>
if (Meteor.isServer) {
Threads.allow({
insert: function (userId, doc) {
if(!userId)
throw new Meteor.Error('Unauthorized', 'Please login before perform an action');
check(doc.title, String);
if (doc.owner && doc.owner != userId)
throw new Meteor.Error('No permission', 'Can\'t create a thread in the name of other');
doc.owner = userId;
doc.createdAt = new Date();
if (Meteor.isServer) {
Threads.allow({
remove: function (userId, doc) {
if(!userId)
throw new Meteor.Error('Unauthorized', 'Please login before perform an action');
return result = doc.owner === userId;
}
});
}
Meteor.methods({
'Threads.create': function (title) {
if (!this.userId)
throw new Meteor.Error('Unauthorized', 'Please login before perform an action');
check(title, String);
Threads.insert({
title: title,
owner: this.userId,
createdAt: new Date(),
updatedAt: new Date()
Meteor.methods({
'Threads.delete': function (threadId) {
if (!this.userId)
throw new Meteor.Error('Unauthorized', 'Please login before perform an action');
check(threadId, String);
Threads.remove({
_id: threadId,
owner: this.userId,
});
return { message: 'Threads.delete OK' };
@varavut
varavut / caddy-part1-docker-compose.yml
Created May 13, 2017 08:37
caddy-part1-docker-compose.yml
version: "2"
services:
caddy:
image: abiosoft/caddy:latest
container_name: caddy
ports:
- "80:80"
- "443:443"
....
furyform.com:
image: furyform:latest
build: ../furyform.com
container_name: furyform.com
environment:
- "NODE_ENV=production"
version: "2"
services:
caddy:
image: abiosoft/caddy:latest
container_name: caddy
ports:
- "80:80"
- "443:443"