File tree Expand file tree Collapse file tree 4 files changed +18
-4
lines changed Expand file tree Collapse file tree 4 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,7 @@ in response to HTTP requests.
13
13
14
14
This Analytics API maintains the schema for the database that the
15
15
[ Analytics Reporter] ( https://github.com/18F/analytics-reporter )
16
- writes to.
17
- Thus, the Analytics API must be setup and
16
+ writes to. Thus, the Analytics API must be setup and
18
17
configured before the Analytics Reporter starts writing data.
19
18
20
19
First, create the database:
@@ -23,6 +22,10 @@ First, create the database:
23
22
createdb analytics-reporter
24
23
```
25
24
25
+ ```` bash
26
+ export NODE_ENV=development # developing locally
27
+ ````
28
+
26
29
Once the database is created, clone the app and install the dependencies via NPM.
27
30
The install script has a postinstall hook that will migrate
28
31
the database.
@@ -48,6 +51,7 @@ is configured to write to the same database and run with the `--write-to-databas
48
51
# Using the API
49
52
50
53
The Analytics API exposes 3 API endpoints:
54
+ include version in the request, ie ` /v1.1/ `
51
55
52
56
- ` /reports/:report_name/data `
53
57
- ` /agencies/:agency_name/reports/:reportName/data `
Original file line number Diff line number Diff line change
1
+ export NODE_ENV=development
2
+ export POSTGRES_USER=postgres
3
+ export POSTGRES_PASSWORD=123abc
4
+ POSTGRES_DATABASE=analytics-reporter
Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ module.exports = {
2
2
development : {
3
3
client : 'postgresql' ,
4
4
connection : {
5
- database : 'analytics-reporter'
5
+ user : process . env . POSTGRES_USER || 'postgres' ,
6
+ password : process . env . POSTGRES_PASSWORD || '123abc' ,
7
+ database : process . env . POSTGRES_DATABASE || 'analytics-reporter' ,
6
8
}
7
9
} ,
8
10
production : {
Original file line number Diff line number Diff line change @@ -3,13 +3,17 @@ const config = require('./config');
3
3
const apiDataGovFilter = ( req , res , next ) => {
4
4
if ( ! config . api_data_gov_secret || req . path === '/' ) {
5
5
return next ( ) ;
6
- } else if ( req . headers [ 'api-data-gov-secret' ] !== config . api_data_gov_secret ) {
6
+ }
7
+ else if ( process . env . NODE_ENV !== 'development' ) {
8
+ console . log ( 'inside' )
9
+ if ( req . headers [ 'api-data-gov-secret' ] !== config . api_data_gov_secret ) {
7
10
res . status ( 403 ) ;
8
11
return res . json ( {
9
12
message : 'Unauthorized. See https://analytics.usa.gov/developer' ,
10
13
status : 403
11
14
} ) ;
12
15
}
16
+ }
13
17
return next ( ) ;
14
18
} ;
15
19
You can’t perform that action at this time.
0 commit comments