Skip to content

Commit

Permalink
Adding test, update version and README
Browse files Browse the repository at this point in the history
  • Loading branch information
C0r3y8 committed Dec 2, 2016
1 parent 49ae8ee commit 494c4b2
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.build*
.npm
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# `ssr-wpo:meteor-koa`
[Koa](http://koajs.com/) next generation web framework with Meteor

## Table of contents
- [Installation](#installation)
- [Api](#api)
- [Example](#example)
- [Additional koa packages](#additional)
- [Testing](#testing)

## <a name='installation'>Installation</a>
```bash
$ meteor add ssr-wpo:meteor-koa
```

## <a name='api'>Api</a>
See [koa api](https://github.com/koajs/koa/tree/v2.x) for more details.

## <a name='example'>Example</a>
`meteor-koa` is only available on server side. (`Meteor.isServer`)

```javascript
import { koa } from 'meteor/ssr-wpo:meteor-koa';

const app = koa();

app.use((ctx) => {
ctx.body = 'Hello World';
});
```

## <a name='additional'>Additional koa packages</a>
Koa has many additional packages listed [here](https://github.com/koajs/koa/wiki).

You can use them with `meteor-koa`, just simply add them with `npm` in your meteor project:
```bash
$ meteor npm install <koa-plugins>
```

## <a name='testing'>Testing</a>
```bash
$ meteor test-packages ./ --driver-package practicalmeteor:mocha
```
### With [spacejam](https://www.npmjs.com/package/spacejam)
```bash
$ spacejam-mocha ./
```
28 changes: 20 additions & 8 deletions meteor-koa-tests.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
// Import Tinytest from the tinytest Meteor package.
import { Tinytest } from "meteor/tinytest";
import { WebApp } from 'meteor/webapp';

// Import and rename a variable exported by meteor-koa.js.
import { name as packageName } from "meteor/meteor-koa";
import { assert } from 'meteor/practicalmeteor:chai';

// Write your tests here!
// Here is an example.
Tinytest.add('meteor-koa - example', function (test) {
test.equal(packageName, "meteor-koa");
import { koa } from 'meteor/meteor-koa';
import { createRequest } from 'meteor/meteor-koa-testing';

const app = koa();

app.use((ctx) => {
ctx.body = 'Hello World';
});

const request = createRequest(app.listen());

describe('meteor koa - Hello World', function () {
it('should say "Hello World"', function (done) {
request
.get('/')
.expect(200)
.expect('Hello World', done);
});
});
4 changes: 3 additions & 1 deletion meteor-koa.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { WebApp } from 'meteor/webapp';

export const koa = function () {
const app = new Koa();
WebApp.connectHandlers.use(Meteor.bindEnvironment(app.callback()));
if (!Meteor.isPackageTest) {
WebApp.connectHandlers.use(Meteor.bindEnvironment(app.callback()));
}
return app;
};
15 changes: 11 additions & 4 deletions package.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package.describe({
name: 'meteor-koa',
version: '0.0.1',
version: '0.1.0',
// Brief, one-line summary of the package.
summary: 'Koa next generation web framework for Meteor',
summary: 'Koa next generation web framework with Meteor',
// URL to the Git repository containing the source code for this package.
git: 'https://github.com/ssr-server/meteor-koa',
// By default, Meteor will default to using README.md for documentation.
Expand All @@ -26,7 +26,14 @@ Package.onUse(function(api) {

Package.onTest(function(api) {
api.use('ecmascript');
api.use('tinytest');

api.use('webapp', 'server');

api.use('practicalmeteor:mocha');
api.use('practicalmeteor:chai');

api.use('meteor-koa');
api.mainModule('meteor-koa-tests.js');
api.use('meteor-koa-testing');

api.mainModule('meteor-koa-tests.js', 'server');
});

0 comments on commit 494c4b2

Please sign in to comment.