The Server-Side of the PeerStreet Challenge
This implements a REST API server that returns population data based on ZIP code.
- Node.js
- Koa
- Knex
- PostgreSQL
Start up psql as a privileged user
sudo su - postgres
psql
Create a user
CREATE USER ps WITH PASSWORD 'ps' SUPERUSER;
-- PostgreSQL requires that a user have SUPERUSER privileges
-- in order to use COPY to do a CSV import.
Create a database.
CREATE DATABASE peerstreet;
Clone the git repo.
git clone https://github.com/beppu/peerstreet-server.git
cd peerstreet-server
Create a .env
file with the following contents.
DB_HOST=localhost
DB_NAME=peerstreet
DB_USER=ps
DB_PASSWORD=ps
PORT=4200
Install node module dependencies.
npm i
Run migrations.
node_modules/.bin/knex migrate:latest
Start the server.
npm start
I would have normally put it in another repo, but the instructions seemed to imply that one repo should be delivered, so I put it in this repo in peerstreet-client/ .
- bin/db - Start
psql
with credentials from.env
- bin/repl - Start a Node.js REPL with preloads defined in
.repl.js