This commit is contained in:
Michael Zhang 2020-11-26 23:33:53 -06:00
commit 032143d9f7
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
22 changed files with 934 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
node_modules/
/.cache
/.meteor

7
client/main.html Normal file
View file

@ -0,0 +1,7 @@
<head>
<title>zhao</title>
</head>
<body>
<div id="app"></div>
</body>

12
client/main.js Normal file
View file

@ -0,0 +1,12 @@
import Vue from 'vue'
import '../imports/ui/plugins'
import App from '../imports/ui/App.vue'
Meteor.startup(() => {
new Vue({
el: '#app',
...App,
})
})

View file

@ -0,0 +1,3 @@
import { Mongo } from 'meteor/mongo';
export default new Mongo.Collection('links');

View file

@ -0,0 +1,24 @@
// Tests for the behavior of the links collection
//
// https://guide.meteor.com/testing.html
import { Meteor } from 'meteor/meteor';
import { assert } from 'chai';
import Links from './Links.js';
if (Meteor.isServer) {
describe('links collection', function () {
it('insert correctly', function () {
const linkId = Links.insert({
title: 'meteor homepage',
url: 'https://www.meteor.com',
});
const added = Links.find({ _id: linkId });
const collectionName = added._getCollectionName();
const count = added.count();
assert.equal(collectionName, 'links');
assert.equal(count, 1);
});
});
}

View file

@ -0,0 +1,3 @@
import { Mongo } from "meteor/mongo";
export default new Mongo.Collection("rooms");

32
imports/api/fixtures.js Normal file
View file

@ -0,0 +1,32 @@
import { Meteor } from 'meteor/meteor';
import Links from './collections/Links.js';
Meteor.startup(() => {
// if the Links collection is empty
if (Links.find().count() === 0) {
const data = [
{
title: 'Do the Tutorial',
url: 'https://www.meteor.com/try',
createdAt: new Date(),
},
{
title: 'Follow the Guide',
url: 'http://guide.meteor.com',
createdAt: new Date(),
},
{
title: 'Read the Docs',
url: 'https://docs.meteor.com',
createdAt: new Date(),
},
{
title: 'Discussions',
url: 'https://forums.meteor.com',
createdAt: new Date(),
},
];
data.forEach(link => Links.insert(link));
}
});

View file

@ -0,0 +1,16 @@
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Links from '../collections/Links.js';
Meteor.methods({
'createLink'(title, url) {
check(url, String);
check(title, String);
return Links.insert({
url,
title,
createdAt: new Date(),
});
},
});

View file

@ -0,0 +1,20 @@
import { Meteor } from 'meteor/meteor';
import { assert } from 'chai';
import Links from '../collections/Links.js';
import './methods.js';
if (Meteor.isServer) {
describe('method: createLink', function () {
beforeEach(function () {
Links.remove({});
});
it('can add a new link', function () {
const addLink = Meteor.server.method_handlers['createLink'];
addLink.apply({}, ['meteor.com', 'https://www.meteor.com']);
assert.equal(Links.find().count(), 1);
});
});
}

View file

@ -0,0 +1 @@
import './createLink'

View file

@ -0,0 +1 @@
import './links'

View file

@ -0,0 +1,6 @@
import { Meteor } from 'meteor/meteor';
import Links from '../collections/Links.js';
Meteor.publish('links', function () {
return Links.find();
});

View file

@ -0,0 +1,22 @@
import { assert } from 'chai'
import { PublicationCollector } from 'meteor/johanbrook:publication-collector'
import Links from '../collections/Links.js'
import './publications.js'
describe('Publish links', function () {
beforeEach(function () {
Links.remove({})
Links.insert({
title: 'meteor homepage',
url: 'https://www.meteor.com'
})
})
it('sends all links', function (done) {
const collector = new PublicationCollector()
collector.collect('links', (collections) => {
assert.equal(collections.links.length, 1)
done()
})
})
})

37
imports/ui/App.vue Normal file
View file

@ -0,0 +1,37 @@
<template>
<div>
<h1>Welcome to Meteor!</h1>
<hello/>
<info/>
<component v-bind:is="whatScreen"></component>
</div>
</template>
<script>
import Hello from './components/Hello.vue'
import Info from './components/Info.vue'
import Lobby from './components/Lobby.vue'
export default {
components: {
Hello,
Info,
Lobby,
},
data() {
return {
currentRoom: null,
whatScreen: Lobby,
};
},
}
</script>
<style>
body {
font-family: sans-serif;
padding: 10px;
}
</style>

View file

@ -0,0 +1,27 @@
<template>
<div>
<button @click="increment">Click Me</button>
<p>You've pressed the button {{counter}} times.</p>
</div>
</template>
<script>
export default {
data() {
return {
counter: 0,
}
},
methods: {
increment() {
this.counter += 1
}
},
}
</script>
<style scoped>
p {
font-family: serif;
}
</style>

View file

@ -0,0 +1,55 @@
<template>
<div>
<h2>Learn Meteor!</h2>
<ul>
<li>
<form class="info-link-add">
<input type="text" v-model="title" name="title" placeholder="Title" required>
<input type="url" v-model="url" name="url" placeholder="Url" required>
<input type="submit" name="submit" @click="submit($event)" value="Add new link">
</form>
</li>
<li v-for="link in links"><a :href="link.url" target="_blank">{{link.title}}</a></li>
</ul>
</div>
</template>
<script>
import Links from '../../api/collections/Links'
export default {
data() {
return {
title: "",
url: "",
}
},
meteor: {
$subscribe: {
'links': [],
},
links () {
return Links.find({})
},
},
methods: {
submit(event) {
event.preventDefault()
Meteor.call('createLink', this.title, this.url, (error) => {
if (error) {
alert(error.error)
} else {
this.title = ''
this.url = ''
}
})
}
},
}
</script>
<style scoped>
ul {
font-family: monospace;
}
</style>

View file

@ -0,0 +1,16 @@
<template>
<div>
<h1>LOBBY</h1>
<button id="newgame-btn">new game</button>
<button id="joingame-btn">join game</button>
</div>
</template>
<script>
export default {
}
</script>
<style scoped>
</style>

4
imports/ui/plugins.js Normal file
View file

@ -0,0 +1,4 @@
import Vue from 'vue'
import VueMeteorTracker from 'vue-meteor-tracker'
Vue.use(VueMeteorTracker)

599
package-lock.json generated Normal file
View file

@ -0,0 +1,599 @@
{
"name": "zhao",
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"@babel/runtime": {
"version": "7.12.5",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.5.tgz",
"integrity": "sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==",
"requires": {
"regenerator-runtime": "^0.13.4"
}
},
"lodash.omit": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/lodash.omit/-/lodash.omit-4.5.0.tgz",
"integrity": "sha1-brGa5aHuHdnfC5aeZs4Lf6MLXmA="
},
"meteor-node-stubs": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/meteor-node-stubs/-/meteor-node-stubs-1.0.1.tgz",
"integrity": "sha512-I4PE/z7eAl45XEsebHA4pcQbgjqEdK3EBGgiUoIZBi3bMQcMq6blLWZo+WdtK4Or9X4NJOiYWw4GmHiubr3egA==",
"requires": {
"assert": "^1.4.1",
"browserify-zlib": "^0.2.0",
"buffer": "^5.2.1",
"console-browserify": "^1.1.0",
"constants-browserify": "^1.0.0",
"crypto-browserify": "^3.12.0",
"domain-browser": "^1.2.0",
"events": "^3.0.0",
"https-browserify": "^1.0.0",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.0",
"process": "^0.11.10",
"punycode": "^2.1.1",
"querystring-es3": "^0.2.1",
"readable-stream": "^3.3.0",
"stream-browserify": "^2.0.2",
"stream-http": "^3.0.0",
"string_decoder": "^1.2.0",
"timers-browserify": "^2.0.10",
"tty-browserify": "0.0.1",
"url": "^0.11.0",
"util": "^0.11.1",
"vm-browserify": "^1.1.0"
},
"dependencies": {
"asn1.js": {
"version": "4.10.1",
"bundled": true,
"requires": {
"bn.js": "^4.0.0",
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0"
}
},
"assert": {
"version": "1.4.1",
"bundled": true,
"requires": {
"util": "0.10.3"
},
"dependencies": {
"util": {
"version": "0.10.3",
"bundled": true,
"requires": {
"inherits": "2.0.1"
}
}
}
},
"base64-js": {
"version": "1.3.0",
"bundled": true
},
"bn.js": {
"version": "4.11.8",
"bundled": true
},
"brorand": {
"version": "1.1.0",
"bundled": true
},
"browserify-aes": {
"version": "1.2.0",
"bundled": true,
"requires": {
"buffer-xor": "^1.0.3",
"cipher-base": "^1.0.0",
"create-hash": "^1.1.0",
"evp_bytestokey": "^1.0.3",
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"browserify-cipher": {
"version": "1.0.1",
"bundled": true,
"requires": {
"browserify-aes": "^1.0.4",
"browserify-des": "^1.0.0",
"evp_bytestokey": "^1.0.0"
}
},
"browserify-des": {
"version": "1.0.2",
"bundled": true,
"requires": {
"cipher-base": "^1.0.1",
"des.js": "^1.0.0",
"inherits": "^2.0.1",
"safe-buffer": "^5.1.2"
}
},
"browserify-rsa": {
"version": "4.0.1",
"bundled": true,
"requires": {
"bn.js": "^4.1.0",
"randombytes": "^2.0.1"
}
},
"browserify-sign": {
"version": "4.0.4",
"bundled": true,
"requires": {
"bn.js": "^4.1.1",
"browserify-rsa": "^4.0.0",
"create-hash": "^1.1.0",
"create-hmac": "^1.1.2",
"elliptic": "^6.0.0",
"inherits": "^2.0.1",
"parse-asn1": "^5.0.0"
}
},
"browserify-zlib": {
"version": "0.2.0",
"bundled": true,
"requires": {
"pako": "~1.0.5"
}
},
"buffer": {
"version": "5.2.1",
"bundled": true,
"requires": {
"base64-js": "^1.0.2",
"ieee754": "^1.1.4"
}
},
"buffer-xor": {
"version": "1.0.3",
"bundled": true
},
"builtin-status-codes": {
"version": "3.0.0",
"bundled": true
},
"cipher-base": {
"version": "1.0.4",
"bundled": true,
"requires": {
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"console-browserify": {
"version": "1.1.0",
"bundled": true,
"requires": {
"date-now": "^0.1.4"
}
},
"constants-browserify": {
"version": "1.0.0",
"bundled": true
},
"core-util-is": {
"version": "1.0.2",
"bundled": true
},
"create-ecdh": {
"version": "4.0.3",
"bundled": true,
"requires": {
"bn.js": "^4.1.0",
"elliptic": "^6.0.0"
}
},
"create-hash": {
"version": "1.2.0",
"bundled": true,
"requires": {
"cipher-base": "^1.0.1",
"inherits": "^2.0.1",
"md5.js": "^1.3.4",
"ripemd160": "^2.0.1",
"sha.js": "^2.4.0"
}
},
"create-hmac": {
"version": "1.1.7",
"bundled": true,
"requires": {
"cipher-base": "^1.0.3",
"create-hash": "^1.1.0",
"inherits": "^2.0.1",
"ripemd160": "^2.0.0",
"safe-buffer": "^5.0.1",
"sha.js": "^2.4.8"
}
},
"crypto-browserify": {
"version": "3.12.0",
"bundled": true,
"requires": {
"browserify-cipher": "^1.0.0",
"browserify-sign": "^4.0.0",
"create-ecdh": "^4.0.0",
"create-hash": "^1.1.0",
"create-hmac": "^1.1.0",
"diffie-hellman": "^5.0.0",
"inherits": "^2.0.1",
"pbkdf2": "^3.0.3",
"public-encrypt": "^4.0.0",
"randombytes": "^2.0.0",
"randomfill": "^1.0.3"
}
},
"date-now": {
"version": "0.1.4",
"bundled": true
},
"des.js": {
"version": "1.0.0",
"bundled": true,
"requires": {
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0"
}
},
"diffie-hellman": {
"version": "5.0.3",
"bundled": true,
"requires": {
"bn.js": "^4.1.0",
"miller-rabin": "^4.0.0",
"randombytes": "^2.0.0"
}
},
"domain-browser": {
"version": "1.2.0",
"bundled": true
},
"elliptic": {
"version": "6.5.3",
"bundled": true,
"requires": {
"bn.js": "^4.4.0",
"brorand": "^1.0.1",
"hash.js": "^1.0.0",
"hmac-drbg": "^1.0.0",
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0",
"minimalistic-crypto-utils": "^1.0.0"
}
},
"events": {
"version": "3.0.0",
"bundled": true
},
"evp_bytestokey": {
"version": "1.0.3",
"bundled": true,
"requires": {
"md5.js": "^1.3.4",
"safe-buffer": "^5.1.1"
}
},
"hash-base": {
"version": "3.0.4",
"bundled": true,
"requires": {
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"hash.js": {
"version": "1.1.7",
"bundled": true,
"requires": {
"inherits": "^2.0.3",
"minimalistic-assert": "^1.0.1"
},
"dependencies": {
"inherits": {
"version": "2.0.3",
"bundled": true
}
}
},
"hmac-drbg": {
"version": "1.0.1",
"bundled": true,
"requires": {
"hash.js": "^1.0.3",
"minimalistic-assert": "^1.0.0",
"minimalistic-crypto-utils": "^1.0.1"
}
},
"https-browserify": {
"version": "1.0.0",
"bundled": true
},
"ieee754": {
"version": "1.1.13",
"bundled": true
},
"inherits": {
"version": "2.0.1",
"bundled": true
},
"isarray": {
"version": "1.0.0",
"bundled": true
},
"md5.js": {
"version": "1.3.5",
"bundled": true,
"requires": {
"hash-base": "^3.0.0",
"inherits": "^2.0.1",
"safe-buffer": "^5.1.2"
}
},
"miller-rabin": {
"version": "4.0.1",
"bundled": true,
"requires": {
"bn.js": "^4.0.0",
"brorand": "^1.0.1"
}
},
"minimalistic-assert": {
"version": "1.0.1",
"bundled": true
},
"minimalistic-crypto-utils": {
"version": "1.0.1",
"bundled": true
},
"os-browserify": {
"version": "0.3.0",
"bundled": true
},
"pako": {
"version": "1.0.10",
"bundled": true
},
"parse-asn1": {
"version": "5.1.4",
"bundled": true,
"requires": {
"asn1.js": "^4.0.0",
"browserify-aes": "^1.0.0",
"create-hash": "^1.1.0",
"evp_bytestokey": "^1.0.0",
"pbkdf2": "^3.0.3",
"safe-buffer": "^5.1.1"
}
},
"path-browserify": {
"version": "1.0.0",
"bundled": true
},
"pbkdf2": {
"version": "3.0.17",
"bundled": true,
"requires": {
"create-hash": "^1.1.2",
"create-hmac": "^1.1.4",
"ripemd160": "^2.0.1",
"safe-buffer": "^5.0.1",
"sha.js": "^2.4.8"
}
},
"process": {
"version": "0.11.10",
"bundled": true
},
"process-nextick-args": {
"version": "2.0.0",
"bundled": true
},
"public-encrypt": {
"version": "4.0.3",
"bundled": true,
"requires": {
"bn.js": "^4.1.0",
"browserify-rsa": "^4.0.0",
"create-hash": "^1.1.0",
"parse-asn1": "^5.0.0",
"randombytes": "^2.0.1",
"safe-buffer": "^5.1.2"
}
},
"punycode": {
"version": "2.1.1",
"bundled": true
},
"querystring": {
"version": "0.2.0",
"bundled": true
},
"querystring-es3": {
"version": "0.2.1",
"bundled": true
},
"randombytes": {
"version": "2.1.0",
"bundled": true,
"requires": {
"safe-buffer": "^5.1.0"
}
},
"randomfill": {
"version": "1.0.4",
"bundled": true,
"requires": {
"randombytes": "^2.0.5",
"safe-buffer": "^5.1.0"
}
},
"readable-stream": {
"version": "3.3.0",
"bundled": true,
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
},
"dependencies": {
"inherits": {
"version": "2.0.3",
"bundled": true
}
}
},
"ripemd160": {
"version": "2.0.2",
"bundled": true,
"requires": {
"hash-base": "^3.0.0",
"inherits": "^2.0.1"
}
},
"safe-buffer": {
"version": "5.1.2",
"bundled": true
},
"setimmediate": {
"version": "1.0.5",
"bundled": true
},
"sha.js": {
"version": "2.4.11",
"bundled": true,
"requires": {
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"stream-browserify": {
"version": "2.0.2",
"bundled": true,
"requires": {
"inherits": "~2.0.1",
"readable-stream": "^2.0.2"
},
"dependencies": {
"readable-stream": {
"version": "2.3.6",
"bundled": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
},
"dependencies": {
"inherits": {
"version": "2.0.3",
"bundled": true
}
}
},
"string_decoder": {
"version": "1.1.1",
"bundled": true,
"requires": {
"safe-buffer": "~5.1.0"
}
}
}
},
"stream-http": {
"version": "3.0.0",
"bundled": true,
"requires": {
"builtin-status-codes": "^3.0.0",
"inherits": "^2.0.1",
"readable-stream": "^3.0.6",
"xtend": "^4.0.0"
}
},
"string_decoder": {
"version": "1.2.0",
"bundled": true,
"requires": {
"safe-buffer": "~5.1.0"
}
},
"timers-browserify": {
"version": "2.0.10",
"bundled": true,
"requires": {
"setimmediate": "^1.0.4"
}
},
"tty-browserify": {
"version": "0.0.1",
"bundled": true
},
"url": {
"version": "0.11.0",
"bundled": true,
"requires": {
"punycode": "1.3.2",
"querystring": "0.2.0"
},
"dependencies": {
"punycode": {
"version": "1.3.2",
"bundled": true
}
}
},
"util": {
"version": "0.11.1",
"bundled": true,
"requires": {
"inherits": "2.0.3"
},
"dependencies": {
"inherits": {
"version": "2.0.3",
"bundled": true
}
}
},
"util-deprecate": {
"version": "1.0.2",
"bundled": true
},
"vm-browserify": {
"version": "1.1.0",
"bundled": true
},
"xtend": {
"version": "4.0.1",
"bundled": true
}
}
},
"regenerator-runtime": {
"version": "0.13.7",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz",
"integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew=="
},
"vue": {
"version": "2.6.12",
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.12.tgz",
"integrity": "sha512-uhmLFETqPPNyuLLbsKz6ioJ4q7AZHzD8ZVFNATNyICSZouqP2Sz0rotWQC8UNBF6VGSCs5abnKJoStA6JbCbfg=="
},
"vue-meteor-tracker": {
"version": "2.0.0-beta.5",
"resolved": "https://registry.npmjs.org/vue-meteor-tracker/-/vue-meteor-tracker-2.0.0-beta.5.tgz",
"integrity": "sha512-egEEqAeKoy7moc4mdb/yM4+UDxk7yOAiIAW8gFz8umtAEYr7Ll8B1wLC0gtoY4IDUU8bCo0UzQjWvfXDMfl7YA==",
"requires": {
"lodash.omit": "^4.5.0"
}
}
}
}

23
package.json Normal file
View file

@ -0,0 +1,23 @@
{
"name": "zhao",
"private": true,
"scripts": {
"start": "meteor run",
"test": "meteor test --once --driver-package meteortesting:mocha",
"test-app": "TEST_WATCH=1 meteor test --full-app --driver-package meteortesting:mocha",
"visualize": "meteor --production --extra-packages bundle-visualizer"
},
"dependencies": {
"@babel/runtime": "^7.11.2",
"meteor-node-stubs": "^1.0.1",
"vue": "^2.6.12",
"vue-meteor-tracker": "^2.0.0-beta.5"
},
"meteor": {
"mainModule": {
"client": "client/main.js",
"server": "server/main.js"
},
"testModule": "tests/main.js"
}
}

3
server/main.js Normal file
View file

@ -0,0 +1,3 @@
import '../imports/api/fixtures'
import '../imports/api/methods'
import '../imports/api/publications'

20
tests/main.js Normal file
View file

@ -0,0 +1,20 @@
import assert from "assert";
describe("skel", function () {
it("package.json has correct name", async function () {
const { name } = await import("../package.json");
assert.strictEqual(name, "skel");
});
if (Meteor.isClient) {
it("client is not server", function () {
assert.strictEqual(Meteor.isServer, false);
});
}
if (Meteor.isServer) {
it("server is not client", function () {
assert.strictEqual(Meteor.isClient, false);
});
}
});