Skip to content

Commit

Permalink
Step 4.3: Move stubs data to the server side
Browse files Browse the repository at this point in the history
  • Loading branch information
DAB0mB committed Feb 13, 2017
1 parent ebf4d68 commit 99caf66
Showing 1 changed file with 67 additions and 2 deletions.
69 changes: 67 additions & 2 deletions server/main.ts
@@ -1,5 +1,70 @@
import { Meteor } from 'meteor/meteor';
import * as Moment from 'moment';
import { Chats, Messages } from '../imports/collections';
import { MessageType } from '../imports/models';

Meteor.startup(() => {
// code to run on server at startup
});
if (Chats.find({}).cursor.count() === 0) {
let chatId;

chatId = Chats.collection.insert({
title: 'Ethan Gonzalez',
picture: 'https://randomuser.me/api/portraits/thumb/men/1.jpg'
});

Messages.collection.insert({
chatId: chatId,
content: 'You on your way?',
createdAt: Moment().subtract(1, 'hours').toDate(),
type: MessageType.TEXT
});

chatId = Chats.collection.insert({
title: 'Bryan Wallace',
picture: 'https://randomuser.me/api/portraits/thumb/lego/1.jpg'
});

Messages.collection.insert({
chatId: chatId,
content: 'Hey, it\'s me',
createdAt: Moment().subtract(2, 'hours').toDate(),
type: MessageType.TEXT
});

chatId = Chats.collection.insert({
title: 'Avery Stewart',
picture: 'https://randomuser.me/api/portraits/thumb/women/1.jpg'
});

Messages.collection.insert({
chatId: chatId,
content: 'I should buy a boat',
createdAt: Moment().subtract(1, 'days').toDate(),
type: MessageType.TEXT
});

chatId = Chats.collection.insert({
title: 'Katie Peterson',
picture: 'https://randomuser.me/api/portraits/thumb/women/2.jpg'
});

Messages.collection.insert({
chatId: chatId,
content: 'Look at my mukluks!',
createdAt: Moment().subtract(4, 'days').toDate(),
type: MessageType.TEXT
});

chatId = Chats.collection.insert({
title: 'Ray Edwards',
picture: 'https://randomuser.me/api/portraits/thumb/men/2.jpg'
});

Messages.collection.insert({
chatId: chatId,
content: 'This is wicked good ice cream.',
createdAt: Moment().subtract(2, 'weeks').toDate(),
type: MessageType.TEXT
});
}
});

0 comments on commit 99caf66

Please sign in to comment.