-
Notifications
You must be signed in to change notification settings - Fork 160
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
Showing
5 changed files
with
41 additions
and
32 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
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
37 changes: 37 additions & 0 deletions
37
packages/fastboot-app-server/test/fixtures/cluster-worker-start.js
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,37 @@ | ||
'use strict'; | ||
|
||
const ClusterWorker = require('../../src/worker'); | ||
|
||
class CustomClusterWorker extends ClusterWorker {} | ||
|
||
function setStatusCode418(req, res, next) { | ||
res.status(418); | ||
next(); | ||
} | ||
|
||
function setXTestHeader(req, res, next) { | ||
res.set('X-Test-Header', 'testing') | ||
next(); | ||
} | ||
|
||
function sendJsonAndTerminate(req, res, next) { | ||
res.json({ send: 'json back' }); | ||
res.send(); | ||
} | ||
|
||
function beforeMiddleware(app) { | ||
app.use(setStatusCode418); | ||
app.use(setXTestHeader); | ||
app.use(sendJsonAndTerminate); | ||
} | ||
|
||
function afterMiddleware(app) { | ||
app.use(setXTestHeader); | ||
} | ||
|
||
const worker = new CustomClusterWorker({ | ||
beforeMiddleware, | ||
afterMiddleware, | ||
}); | ||
|
||
worker.start(); |