diff options
author | Brandon Millman <brandon@0xproject.com> | 2017-12-14 07:09:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-14 07:09:39 +0800 |
commit | 2ef763a19555b85814a80aa5d93a14c90c51c512 (patch) | |
tree | 5b41b8911e12569f669fc7b30f3ea2cc19a33611 /packages/kovan-faucets/src/ts/server.ts | |
parent | 6bda6a22e3551707e7069e8ad6ea34d1ba0abd4d (diff) | |
parent | 6ba4ed99c42b4976902046625790698b490c3e0e (diff) | |
download | dexon-sol-tools-2ef763a19555b85814a80aa5d93a14c90c51c512.tar dexon-sol-tools-2ef763a19555b85814a80aa5d93a14c90c51c512.tar.gz dexon-sol-tools-2ef763a19555b85814a80aa5d93a14c90c51c512.tar.bz2 dexon-sol-tools-2ef763a19555b85814a80aa5d93a14c90c51c512.tar.lz dexon-sol-tools-2ef763a19555b85814a80aa5d93a14c90c51c512.tar.xz dexon-sol-tools-2ef763a19555b85814a80aa5d93a14c90c51c512.tar.zst dexon-sol-tools-2ef763a19555b85814a80aa5d93a14c90c51c512.zip |
Merge pull request #229 from 0xProject/feature/addKovanFaucets
Add kovan faucet project into the mono repo
Diffstat (limited to 'packages/kovan-faucets/src/ts/server.ts')
-rw-r--r-- | packages/kovan-faucets/src/ts/server.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/kovan-faucets/src/ts/server.ts b/packages/kovan-faucets/src/ts/server.ts new file mode 100644 index 000000000..fbb9caf1e --- /dev/null +++ b/packages/kovan-faucets/src/ts/server.ts @@ -0,0 +1,26 @@ +import * as bodyParser from 'body-parser'; +import * as express from 'express'; + +import {errorReporter} from './error_reporter'; +import {Handler} from './handler'; + +// Setup the errorReporter to catch uncaught exceptions and unhandled rejections +errorReporter.setup(); + +const app = express(); +app.use(bodyParser.json()); // for parsing application/json +app.use((req, res, next) => { + res.header('Access-Control-Allow-Origin', '*'); + res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); + next(); +}); + +const handler = new Handler(); +app.get('/ping', (req: express.Request, res: express.Response) => { res.status(200).send('pong'); }); +app.get('/ether/:recipient', handler.dispenseEther.bind(handler)); +app.get('/zrx/:recipient', handler.dispenseZRX.bind(handler)); + +// Log to rollbar any errors unhandled by handlers +app.use(errorReporter.errorHandler()); +const port = process.env.PORT || 3000; +app.listen(port); |