-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
supporting find-my-way router override
- Loading branch information
1 parent
40cc09d
commit ac12400
Showing
4 changed files
with
62 additions
and
5 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
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 @@ | ||
const anumargak = require('anumargak') | ||
|
||
const service = require('./../index')({ | ||
routerFactory: (options) => { | ||
console.log('creating anumargak router...') | ||
return anumargak(options) | ||
} | ||
}) | ||
|
||
service.get('/hi', (req, res) => { | ||
res.send('Hello World!') | ||
}) | ||
service.start() |
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,31 @@ | ||
/* global describe, it */ | ||
const request = require('supertest') | ||
|
||
describe('Router Factory - overriding find-my-way router with "anumargak"', () => { | ||
let server | ||
const anumargak = require('anumargak') | ||
|
||
const service = require('../index')({ | ||
routerFactory: (options) => { | ||
console.log('creating anumargak router...') | ||
return anumargak(options) | ||
} | ||
}) | ||
service.get('/hello', (req, res) => { | ||
res.send(200) | ||
}) | ||
|
||
it('should start the service with "anumargak" router', async () => { | ||
server = await service.start(~~process.env.PORT) | ||
}) | ||
|
||
it('should GET 200 on /hello', async () => { | ||
await request(server) | ||
.get('/hello') | ||
.expect(200) | ||
}) | ||
|
||
it('should successfully terminate the service', async () => { | ||
await service.close() | ||
}) | ||
}) |