This repository has been archived by the owner on Nov 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV-147 added basic framework for API server and database connection …
…with roles and users
- Loading branch information
Showing
36 changed files
with
7,916 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Javascript Node CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details | ||
# | ||
version: 2 | ||
|
||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/node:9.6.1 | ||
- environment: | ||
- NODE_ENV: test | ||
- DB_USER: root | ||
- DB_PASS: test | ||
- DB_HOST: 127.0.0.1 | ||
- DB_NAME: circle-test | ||
|
||
- image: circleci/postgres:9.6.2-alpine | ||
- environment: | ||
- POSTGRES_USER: root | ||
- POSTGRES_PASS: test | ||
- POSTGRES_DB: circle-test | ||
|
||
steps: | ||
- checkout | ||
|
||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "package.json" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
|
||
- run: | ||
name: Postgres Client | ||
command: sudo apt install postgresql-client | ||
|
||
- run: | ||
name: Install global packages | ||
command: sudo npm install -g truffle codecov greenkeeper-lockfile@1 | ||
|
||
- run: | ||
name: Greenkeeper Lockfile | ||
command: greenkeeper-lockfile-update | ||
|
||
- run: | ||
name: Install dependencies | ||
command: npm install | ||
|
||
- save_cache: | ||
key: v1-dependencies-{{ checksum "package.json" }} | ||
paths: | ||
- node_modules | ||
|
||
- run: | ||
name: Javascript Linter | ||
command: npm run lint | ||
|
||
- run: | ||
name: Unit Tests | ||
command: npm test | ||
|
||
- run: | ||
name: Database Tests | ||
command: npm run test:db | ||
|
||
- run: | ||
name: Server Tests | ||
command: npm run test:server | ||
|
||
# - run: | ||
# name: Unit tests with code coverage | ||
# command: npm run test:cov | ||
# | ||
- run: | ||
name: Push any lockfile changes | ||
command: greenkeeper-lockfile-upload | ||
|
||
# - run: | ||
# name: Send reports to codecov.io | ||
# command: codecov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": ["standard", "prettier", "prettier/standard"], | ||
"plugins": ["prettier", "standard", "mocha"], | ||
"parserOptions": { | ||
"sourceType": "module" | ||
}, | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"rules": { | ||
"prettier/prettier": ["error", { "singleQuote": true, "semi": false }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// can't be in ES6 syntax | ||
|
||
var path = require('path'); | ||
|
||
module.exports = { | ||
'config': path.resolve(__dirname, 'config', 'config.json'), | ||
'migrations-path': path.resolve(__dirname, 'migrations'), | ||
'models-path': path.resolve(__dirname, 'src', 'models') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM 'node:9-alpine' | ||
MAINTAINER 'Dave Sag <[email protected]>' | ||
|
||
RUN apk add --update postgresql-client | ||
|
||
# Create app directory | ||
WORKDIR /usr/src/app | ||
|
||
# Install app dependencies | ||
# A wildcard is used to ensure both package.json AND package-lock.json are copied | ||
# where available (npm@5+) | ||
COPY package*.json ./ | ||
|
||
# Build code for development | ||
RUN npm install | ||
|
||
# Bundle app source | ||
COPY . . | ||
|
||
# expose the port | ||
EXPOSE 3000 | ||
|
||
# start it | ||
CMD [ "npm", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"development": { | ||
"username": "docker", | ||
"password": "docker", | ||
"database": "c4coin-api-cs-dev", | ||
"host": "localhost", | ||
"dialect": "postgres" | ||
}, | ||
"test": { | ||
"username": "docker", | ||
"password": "docker", | ||
"database": "c4coin-api-cs-test", | ||
"host": "localhost", | ||
"dialect": "postgres" | ||
}, | ||
"production": { | ||
"username": "docker", | ||
"password": "docker", | ||
"database": "c4coin-api-cs-prod", | ||
"host": "localhost", | ||
"dialect": "postgres" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
version: "3" | ||
volumes: | ||
# We'll define a volume that will store the data from the postgres databases: | ||
postgres-data: | ||
driver: local | ||
|
||
services: | ||
db: | ||
# replace username/repo:tag with your name and image details | ||
image: postgres:9.6.2 | ||
ports: | ||
- 5432:5432 | ||
volumes: | ||
- postgres-data:/var/lib/postgresql | ||
healthcheck: | ||
test: "exit 0" | ||
environment: | ||
POSTGRES_USER: docker | ||
POSTGRES_PASSWORD: docker | ||
networks: | ||
- apiserver | ||
server: | ||
build: . | ||
ports: | ||
- 3001:3000 | ||
links: | ||
- db | ||
depends_on: | ||
- db | ||
healthcheck: | ||
test: "exit 0" | ||
environment: | ||
DB_USER: docker | ||
DB_PASS: docker | ||
DB_HOST: db | ||
command: ["./start.sh", "db", "npm", "start"] | ||
networks: | ||
- apiserver | ||
|
||
networks: | ||
apiserver: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const Server = require("./src/server") | ||
|
||
process.on("unhandledRejection", (reason, p) => { | ||
// eslint-disable-next-line no-console | ||
console.log("Unhandled rejection in promise", p, "caused by", reason) | ||
}) | ||
|
||
Server.start() |
Oops, something went wrong.