Skip to content

Commit

Permalink
Merge pull request #1 from UniversityOfHelsinkiCS/trunk
Browse files Browse the repository at this point in the history
Initial
  • Loading branch information
Rochet2 authored Mar 27, 2019
2 parents eb47c4b + 765e517 commit 2e6de8d
Show file tree
Hide file tree
Showing 9 changed files with 3,283 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
.env
40 changes: 40 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
language: node_js
node_js:
- '8'

cache:
directories:
- node_modules

addons:
postgresql: "9.6"
apt:
packages:
- postgresql-9.6
- postgresql-client-9.6

services:
- redis-server
- docker
- postgresql

dist: trusty

env:
global:
- NODE_ENV=test
- DB_URL=postgres://postgres@localhost/ooditest

before_script:
- psql --version
- psql -c 'create database ooditest' -U postgres
- psql -l

script:
- if [[ $TRAVIS_BRANCH =~ (^master) ]]; then docker build -t toska/oodikone2-analytics:staging .; fi
- if [[ $TRAVIS_BRANCH =~ (^master) ]]; then docker login -u $DOCKER_USER -p $DOCKER_PASS; fi
- if [[ $TRAVIS_BRANCH =~ (^master) ]]; then docker push toska/oodikone2-analytics:staging; fi
- if [[ $TRAVIS_TAG =~ ([0-1].+) ]]; then docker build -t toska/oodikone2-analytics:latest .; fi
- if [[ $TRAVIS_TAG =~ ([0-1].+) ]]; then docker login -u $DOCKER_USER -p $DOCKER_PASS; fi
- if [[ $TRAVIS_TAG =~ ([0-1].+) ]]; then docker push toska/oodikone2-analytics:latest; fi

10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:8.11.3

RUN mkdir -p /usr/src/app
COPY . /usr/src/app
WORKDIR /usr/src/app

RUN npm install
EXPOSE 4568

CMD ["npm", "start"]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# oodikone2-analytics
# oodikone2-analytics

[![Build Status](https://travis-ci.org/UniversityOfHelsinkiCS/oodikone2-analytics.svg?branch=master)](https://travis-ci.org/UniversityOfHelsinkiCS/oodikone2-analytics)
23 changes: 23 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const express = require('express')

const app = express()
const port = 4568
const bodyParser = require('body-parser')

app.use(bodyParser.json())

app.get('/ping', (req, res) => res.json({ message: 'pong '}))

let fetching = false
let data = null
app.get('/data', (req, res) => {
if (fetching) {
return res.json(data)
}
if (!data) {
data = { data: "datahere" } // recalculate?
}
return res.json(data)
})

app.listen(port, () => console.log(`Analytics listening on port ${port}!`))
Loading

0 comments on commit 2e6de8d

Please sign in to comment.