Skip to content

Commit d7efc9f

Browse files
committed
Update README
1 parent d4846e5 commit d7efc9f

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

README.md

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
1-
[![Code Climate](https://codeclimate.com/github/18F/analytics-reporter-api/badges/gpa.svg)](https://codeclimate.com/github/18F/analytics-reporter-api) [![CircleCI](https://circleci.com/gh/18F/analytics-reporter-api.svg?style=shield)](https://circleci.com/gh/18F/analytics-reporter-api) [![Dependency Status](https://gemnasium.com/badges/github.com/18F/analytics-reporter-api.svg)](https://gemnasium.com/github.com/18F/analytics-reporter-api)
2-
3-
1+
[![Code Climate](https://codeclimate.com/github/18F/analytics-reporter-api/badges/gpa.svg)](https://codeclimate.com/github/18F/analytics-reporter-api) [![CircleCI](https://circleci.com/gh/18F/analytics-reporter-api.svg?style=shield)](https://circleci.com/gh/18F/analytics-reporter-api)
42

53
# Analytics API
64

75
A system for publishing data retrieved from the Google Analytics API by the
86
[Analytics Reporter](https://github.com/18F/analytics-reporter).
9-
This Analytics API serves data written to a PostgreSQL database by the Analytics Reporter,
10-
in response to HTTP requests.
7+
This Analytics API serves data written to a PostgreSQL database by the Analytics
8+
Reporter, in response to HTTP requests.
119

12-
# Setup
10+
## Setup
1311

1412
This Analytics API maintains the schema for the database that the
1513
[Analytics Reporter](https://github.com/18F/analytics-reporter)
1614
writes to. Thus, the Analytics API must be setup and
1715
configured before the Analytics Reporter starts writing data.
1816

19-
First, create the database:
17+
### Prerequistites
2018

21-
```shell
22-
createdb analytics-reporter
23-
```
19+
* NodeJS > v20.x
20+
* A postgres DB running
2421

25-
````bash
26-
export NODE_ENV=development # developing locally
27-
````
22+
### Clone the code and install dependencies
2823

2924
Once the database is created, clone the app and install the dependencies via NPM.
3025
The install script has a postinstall hook that will migrate
@@ -44,22 +39,23 @@ npm start
4439

4540
The API should now be available at `http://localhost:4444/`
4641

47-
Note that the API will not render any data until
48-
[Analytics Reporter](https://github.com/18F/analytics-reporter)
49-
is configured to write to the same database and run with the `--write-to-database` option.
42+
Note that the API will not render any data because the database is empty.
43+
The [Analytics Reporter](https://github.com/18F/analytics-reporter)
44+
can be configured to write to the same database and run with the
45+
`--write-to-database` option in order to populate some records.
5046

51-
# Using the API
47+
## Using the API
5248

5349
Full API docs can be found here: https://open.gsa.gov/api/dap/
5450

55-
## Environments
51+
### Environments
5652

5753
The base URLs for the 3 API envrionments:
5854
- development: https://api.gsa.gov/analytics/dap/develop/
5955
- staging: https://api.gsa.gov/analytics/dap/staging/
6056
- production: https://api.gsa.gov/analytics/dap/
6157

62-
## Overview
58+
### Overview
6359

6460
The Analytics API exposes 3 API endpoints:
6561

@@ -73,7 +69,7 @@ are found, an empty array is returned.
7369

7470
Records are sorted according to the associated date.
7571

76-
### Limit query parameter
72+
#### Limit query parameter
7773

7874
If a different number of records is desired, the `limit` query parameter can be
7975
set to specify the desired number of records.
@@ -85,7 +81,7 @@ set to specify the desired number of records.
8581
The maximum number of records that can be rendered for any given request is
8682
10,000.
8783

88-
### Page query parameter
84+
#### Page query parameter
8985

9086
If the desired record does not appear for the current request, the `page` query
9187
parameter can be used to get the next series of data points. Since the data is
@@ -149,7 +145,7 @@ An enum which describes the session. Possible values:
149145
'Direct', 'Organic Search', 'Paid Social', 'Organic Social', 'Email',
150146
'Affiliates', 'Referral', 'Paid Search', 'Video', and 'Display'
151147

152-
# Linting
148+
## Linting
153149

154150
This repo uses Eslint and Prettier for code static analysis and formatting. Run
155151
the linter with:
@@ -164,7 +160,7 @@ Automatically fix lint issues with:
164160
npm run lint:fix
165161
```
166162

167-
# Running the unit tests
163+
## Running the unit tests
168164

169165
The unit tests for this repo require a local PostgreSQL database. You can run a
170166
local DB server or create a docker container using the provided test compose
@@ -187,21 +183,21 @@ Run the tests (pre-test hook runs DB migrations):
187183
npm test
188184
```
189185

190-
# Creating a new database migration
186+
## Creating a new database migration
191187
If you need to migrate the database, you can create a new migration via `knex`, which will create the migration file for you based in part on the migration name you provide. From the root of this repo, run:
192188
```
193189
`npm bin`/knex migrate:make <the name of your migration>
194190
```
195191

196192
See [knex documentation](https://knexjs.org/#Installation-migrations) for more details.
197193

198-
# Running database migrations
194+
## Running database migrations
199195

200-
## Locally
196+
### Locally
201197

202198
`npm run migrate`
203199

204-
## In production
200+
### In production
205201

206202
In production, you can run database migrations via `cf run-task`. As with anything in production, be careful when doing this! First, try checking the current status of migrations using the `migrate:status` command
207203

@@ -230,7 +226,8 @@ cf run-task analytics-reporter-api --command "knex migrate:latest" --name run_db
230226
```
231227

232228
See [knex documentation](https://knexjs.org/#Installation-migrations) for more details and options on the `migrate` command.
233-
### Public domain
229+
230+
## Public domain
234231

235232
This project is in the worldwide [public domain](LICENSE.md). As stated in
236233
[CONTRIBUTING](CONTRIBUTING.md):

0 commit comments

Comments
 (0)