beppu / peerstreet-server

Server-side of PeerStreet Challenge

Home Page:http://peerstreet.bavl.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

peerstreet-server

The Server-Side of the PeerStreet Challenge

About

This implements a REST API server that returns population data based on ZIP code.

Stack

  • Node.js
    • Koa
    • Knex
  • PostgreSQL

Setup

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;

Web Server

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

The Ruby Client

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/ .

Utilities

  • bin/db - Start psql with credentials from .env
  • bin/repl - Start a Node.js REPL with preloads defined in .repl.js

About

Server-side of PeerStreet Challenge

http://peerstreet.bavl.org/

License:MIT License


Languages

Language:JavaScript 78.6%Language:Ruby 15.7%Language:TypeScript 3.4%Language:Shell 2.3%