From bbb768c5cfa8bf713670608f859debae42b42898 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Mon, 20 Nov 2017 13:12:15 -0800 Subject: Add kovan faucet project into the mono repo --- packages/kovan-faucets/src/ts/server.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 packages/kovan-faucets/src/ts/server.ts (limited to 'packages/kovan-faucets/src/ts/server.ts') diff --git a/packages/kovan-faucets/src/ts/server.ts b/packages/kovan-faucets/src/ts/server.ts new file mode 100644 index 000000000..0ae10e556 --- /dev/null +++ b/packages/kovan-faucets/src/ts/server.ts @@ -0,0 +1,27 @@ +import * as bodyParser from 'body-parser'; +import * as express from 'express'; +import {Handler} from './handler'; +import {errorReporter} from './error_reporter'; + +// 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('/rain/:recipient', handler.dispenseEther.bind(handler)); // Deprecated gracefully +app.get('/ether/:recipient', handler.dispenseEther.bind(handler)); +app.get('/zrx/:recipient', handler.dispenseZRX.bind(handler)); +app.get('/queue', handler.getQueueInfo.bind(handler)); // Deprecated gracefully + +// Log to rollbar any errors unhandled by handlers +app.use(errorReporter.errorHandler()); +const port = process.env.PORT || 3000; +app.listen(port); -- cgit v1.2.3 From 1e9f23ebba5e0729b64e757d6901205278871e9f Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 12 Dec 2017 13:06:02 -0800 Subject: Fix build errors --- packages/kovan-faucets/src/ts/server.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'packages/kovan-faucets/src/ts/server.ts') diff --git a/packages/kovan-faucets/src/ts/server.ts b/packages/kovan-faucets/src/ts/server.ts index 0ae10e556..d60363ceb 100644 --- a/packages/kovan-faucets/src/ts/server.ts +++ b/packages/kovan-faucets/src/ts/server.ts @@ -1,7 +1,8 @@ import * as bodyParser from 'body-parser'; import * as express from 'express'; -import {Handler} from './handler'; + import {errorReporter} from './error_reporter'; +import {Handler} from './handler'; // Setup the errorReporter to catch uncaught exceptions and unhandled rejections errorReporter.setup(); -- cgit v1.2.3 From 91f276d9254bba3d93fc821c4fadab2eb6fc1d65 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 12 Dec 2017 17:18:15 -0800 Subject: Cleanup kovan-faucet package --- packages/kovan-faucets/src/ts/server.ts | 2 -- 1 file changed, 2 deletions(-) (limited to 'packages/kovan-faucets/src/ts/server.ts') diff --git a/packages/kovan-faucets/src/ts/server.ts b/packages/kovan-faucets/src/ts/server.ts index d60363ceb..fbb9caf1e 100644 --- a/packages/kovan-faucets/src/ts/server.ts +++ b/packages/kovan-faucets/src/ts/server.ts @@ -17,10 +17,8 @@ app.use((req, res, next) => { const handler = new Handler(); app.get('/ping', (req: express.Request, res: express.Response) => { res.status(200).send('pong'); }); -app.get('/rain/:recipient', handler.dispenseEther.bind(handler)); // Deprecated gracefully app.get('/ether/:recipient', handler.dispenseEther.bind(handler)); app.get('/zrx/:recipient', handler.dispenseZRX.bind(handler)); -app.get('/queue', handler.getQueueInfo.bind(handler)); // Deprecated gracefully // Log to rollbar any errors unhandled by handlers app.use(errorReporter.errorHandler()); -- cgit v1.2.3