-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5784525
commit 22763ca
Showing
15 changed files
with
130 additions
and
28 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,4 @@ | ||
################# | ||
## api secrets ## | ||
################# | ||
JWT_SECRET=secret |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
async function get(ctx) { | ||
ctx.body = 'it worked'; | ||
ctx.body = { breeExists: ctx.bree }; | ||
} | ||
|
||
module.exports = { get }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
const bree = require('./bree'); | ||
const api = require('./api'); | ||
const web = require('./web'); | ||
const proxy = require('./proxy'); | ||
|
||
const config = require('./config'); | ||
|
||
function plugin(opts, Bree) { | ||
opts = { | ||
port: config.port, | ||
...opts | ||
}; | ||
|
||
const oldInit = Bree.prototype.init; | ||
|
||
Bree.prototype.init = function () { | ||
oldInit.bind(this)(); | ||
|
||
// assign bree to the context | ||
api.app.context.bree = this; | ||
|
||
this.api = api; | ||
|
||
this.api.listen(opts.port).catch((err) => { | ||
throw err; | ||
}); | ||
}; | ||
} | ||
|
||
module.exports = { | ||
bree, | ||
api, | ||
web, | ||
proxy | ||
proxy, | ||
plugin | ||
}; |
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Snapshot report for `test/config/utilities.js` | ||
|
||
The actual snapshot is saved in `utilities.js.snap`. | ||
|
||
Generated by [AVA](https://avajs.dev). | ||
|
||
## returns JSON with 2 spaces | ||
|
||
> Snapshot 1 | ||
`{␊ | ||
"ok": "hey"␊ | ||
}` |
Binary file not shown.
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,3 @@ | ||
setTimeout(() => { | ||
console.log('hello'); | ||
}, 100); |
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 @@ | ||
|
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,30 @@ | ||
const test = require('ava'); | ||
|
||
const { baseConfig } = require('../utils'); | ||
|
||
test.beforeEach((t) => { | ||
t.context.Bree = require('bree'); | ||
t.context.plugin = require('../..').plugin; | ||
}); | ||
|
||
test('api does not exist on bree constructor', (t) => { | ||
const { Bree, plugin } = t.context; | ||
|
||
Bree.extend(plugin); | ||
|
||
t.is(typeof Bree.api, 'undefined'); | ||
}); | ||
|
||
test('api does exist on bree instance', (t) => { | ||
const { Bree, plugin } = t.context; | ||
|
||
Bree.extend(plugin); | ||
|
||
const bree = new Bree(baseConfig); | ||
|
||
t.log(bree); | ||
// just to make sure this works correctly | ||
t.is(typeof bree.start, 'function'); | ||
t.log(bree.api); | ||
t.is(typeof bree.api, 'object'); | ||
}); |
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