Skip to content

Commit

Permalink
moving response into lambda utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Edwards authored and Chris Edwards committed Jan 13, 2017
1 parent 06d347b commit 25781c3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
15 changes: 1 addition & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,10 @@ import {
getDistrictByLatLng,
getDistrictByAddress
} from 'congressional-district-finder';
import { response } from './util/lambda';
import { getMembers, setProPublicaKey } from './propublica';


const DEFAULT_HEADERS = {
'Content-Type': 'application/json'
};

function response(body, statusCode = 200, headers = DEFAULT_HEADERS) {
return {
statusCode,
headers,
body: JSON.stringify(
Object.assign({ statusCode }, body)
)
}
}

function handler(event, context, callback) {

const { queryStringParameters } = event;
Expand Down
16 changes: 16 additions & 0 deletions src/util/lambda.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


const DEFAULT_HEADERS = {
'Content-Type': 'application/json'
};


export function response(body, statusCode = 200, headers = DEFAULT_HEADERS) {
return {
statusCode,
headers,
body: JSON.stringify(
Object.assign({ statusCode }, body)
)
}
}

0 comments on commit 25781c3

Please sign in to comment.