| 123456789101112131415161718192021222324252627282930313233 |
- import { Meteor } from 'meteor/meteor';
- import { Mongo } from 'meteor/mongo';
- import { check, Match } from 'meteor/check';
-
- export const Links = new Mongo.Collection('links');
-
- const YTExp = /http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-_]*)/;
-
- if (Meteor.isServer) {
- // This code only runs on the server
- Meteor.publish('links', function linksPublication() {
- return Links.find({
- completed: {$ne: true}
- });
- });
- }
-
- Meteor.methods({
-
- 'links.insert'(url) {
- check(url, Match.Where((url) => YTExp.test(url)));
- Links.insert({
- url,
- createdAt: new Date(),
- });
- },
-
- 'links.remove'(linkId) {
- check(linkId, String);
- Links.remove(linkId);
- },
-
- });
|