-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding test, update version and README
- Loading branch information
Showing
5 changed files
with
83 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.build* | ||
.npm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ./ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters