Skip to content

LewisWatson/carshare-back

Repository files navigation

Car Share Back

Build Status Coverage Status GitPitch stability-experimental

An Open Source API for tracking car shares.

Designed to enable easy tracking of the distance members travel as passengers and as drivers. Car share members can make informed day to day decisions about who should drive next based on the ratio of distance travelled as the driver vs as a passenger.

Written in Go and designed using {json:api} specification for building API's in JSON.

Install

go get github.com/LewisWatson/carshare-back

Run

docker run -d -p 27017:27017 mongo --smallfiles
$GOPATH/bin/carshare-back
1970/01/01 00:00:00 connecting to mongodb server via url: localhost
1970/01/01 00:00:00 listening on :31415

Configuration

$GOPATH/bin/carshare-back --help
usage: carshare-back [<flags>]

API for tracking car shares

Flags:
  --help                        Show context-sensitive help (also try --help-long and --help-man).
  --port=31415                  Set port to bind to
  --mgoURL=localhost            URL to MongoDB server or seed server(s) for clusters
  --firebase="ridesharelogger"  Firebase project to use for authentication
  --cors=URI                    Enable HTTP Access Control (CORS) for the specified URI
  --version                     Show application version.

Docker

The Dockerfile uses a minimal Docker image based on Alpine Linux with a different implimentation of libc. Therefore, it is important that a static binary is used when building

go build -tags 'gingonic netgo' -ldflags '-extldflags "-lm -lstdc++ -static"'
docker build .

Pre-made images are available as lewiswatson/carshare-back

Available endpoints

OPTIONS GET POST PATCH DELETE Path
OPTIONS POST /v0/users
OPTIONS PATCH DELETE /v0/users/:id
OPTIONS POST /v0/trips
OPTIONS GET /v0/trips/:id
GET PATCH /v0/trips/:id/relationships/carShare
GET /v0/trips/:id/carShare
GET PATCH /v0/trips/:id/relationships/driver
GET /v0/trips/:id/driver
GET POST PATCH DELETE /v0/trips/:id/relationships/passengers
GET /v0/trips/:id/passengers
PATCH DELETE /v0/trips/:id
OPTIONS GET POST /v0/carShares
OPTIONS GET PATCH DELETE /v0/carShares/:id
GET POST PATCH DELETE /v0/carShares/:id/relationships/trips
GET /v0/carShares/:id/trips
GET POST PATCH DELETE /v0/carShares/:id/relationships/members
GET POST PATCH DELETE /v0/carShares/:id/members
GET /v0/carShares/:id/relationships/admins
GET /v0/carShares/:id/admins
GET /metrics

Metrics

The /metrics endpoint exposes internal metrics for prometheus monitoring.

License

Copyright 2017 Lewis Watson

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.