Streetlives is a community-built platform for enabling people who are homeless or in poverty to easily find, rate and recommend social services across New York City.
This repository contains the Streetlives back-end server, which provides an API for accessing and interacting with the Streetlives data.
For the Streetlives server to run, it requires a connection to a PostgreSQL database.
You can install and run the database locally (instructions here), or connect to a remote database (for instance on RDS).
See the Configuration section for how to configure the database connection info.
Since Streetlives relies heavily on geographical data, it requires enabling PostGIS (version < 2.2.0) on the database. After installing the PostGIS software locally, connect to the correct database within PostgreSQL (Default: 'streetlives') using psql (or another PostgreSQL management tool) and run:
CREATE EXTENSION postgis;
- Clone the repo:
git clone git@github.com:streetlives/streetlives-api.git
- Install the dependencies:
cd streetlives-api
npm install
-
Set the configuration variables as needed.
-
Run the development server:
npm run dev
- To build and run a distribution build of the server:
npm start
All configuration options can be passed to the server using environment variables. The following variables are supported:
PORT
- The port on which the server will listen to requests (Default: 3000)DATABASE_NAME
- The name of the database used to store Streetlives data (Default: "streetlives")DATABASE_HOST
- The URL at which the database is hostedDATABASE_USER
- The username used to connect to the databaseDATABASE_PASSWORD
- The password used to connect to the database
Environment variables depends on the operating system, but can generally be set in the command-line when running the server.
For example, on Linux/Mac:
DATABASE_HOST=localhost DATABASE_USER=myuser DATABASE_PASSWORD=mypassword npm run dev
Currently, this codebase has only integration tests, testing end-to-end from HTTP request to database.
For them to work, make sure you've configured a DB as specified in the Configuration section, but note that the database name used by tests will always be "test" (to separate it from any DB containing real data, as the tests wipe the data every time they run).
npm run test
npm run test:watch
This project is licensed under the MIT License - see the LICENSE file for details.