Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.docker-compose-dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
POSTGRES_USER=postgres
POSTGRES_PASSWORD=
POSTGRES_DB=postgres

88 changes: 81 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,86 @@
.vs
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Custom
.vs*
.idea
__generated__
build
node_modules
docker-compose.override.yml
npm-error.log*
npm-debug.log*
yarn-error.log*
yarn-debug.log*
lerna-debug.log*
backup.sql
13 changes: 0 additions & 13 deletions .vscode/settings.json

This file was deleted.

19 changes: 0 additions & 19 deletions api/.env

This file was deleted.

13 changes: 13 additions & 0 deletions api/.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
PORT=8080

# DB
PG_LISTINGS_HOST=
PG_LISTINGS_USER=
PG_LISTINGS_PASSWORD=
PG_LISTINGS_DATABASE=

# CORS
API_ORIGIN=http://localhost:8080
CORS_ORIGIN=http://localhost
CRM_ORIGIN=http://localhost:3001

34 changes: 0 additions & 34 deletions api/.vscode/launch.json

This file was deleted.

14 changes: 0 additions & 14 deletions api/.vscode/settings.json

This file was deleted.

47 changes: 0 additions & 47 deletions api/.vscode/snippets/javascript.json

This file was deleted.

14 changes: 14 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:8-alpine

WORKDIR /app

COPY package*.json ./
COPY yarn.lock ./

RUN apk update \
&& apk add --no-cache curl bash \
&& sh -c "curl -o- -L https://yarnpkg.com/install.sh | bash" \
&& yarn install

EXPOSE 8080
CMD [ "yarn", "dev" ]
20 changes: 0 additions & 20 deletions api/docker-compose.yml

This file was deleted.

2 changes: 0 additions & 2 deletions api/images/db/Dockerfile

This file was deleted.

7 changes: 6 additions & 1 deletion api/knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ dotenv.config({ path: '.env' });

module.exports = {
client: 'pg',
connection: {},
connection: {
host: process.env.PG_LISTINGS_HOST,
user: process.env.PG_LISTINGS_USER,
password: process.env.PG_LISTINGS_PASSWORD,
database: process.env.PG_LISTINGS_DATABASE,
},
migrations: {
tableName: 'migrations',
},
Expand Down
23 changes: 23 additions & 0 deletions api/migrations/201902252336_properties_alter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* prettier-ignore */

module.exports.up = async db => {
console.log('append land_surface, number_of_rooms, number_of_parkings to properties table');

await db.schema.alterTable('properties', table => {
table.float('land_surface');
table.float('number_of_rooms');
table.integer('number_of_parkings');
});
};

module.exports.down = async db => {
console.log('drop land_surface, number_of_rooms, number_of_parkings to properties table');

await db.schema.alterTable('properties', table => {
table.dropColumn('land_surface');
table.dropColumn('number_of_rooms');
table.dropColumn('number_of_parkings');
});
};

module.exports.config = { transaction: true };
5 changes: 3 additions & 2 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"graphql-relay": "^0.5.5",
"graphql-type-json": "^0.2.1",
"idx": "^2.2.0",
"knex": "^0.15.2",
"knex": "^0.16.3",
"lodash": "^4.17.4",
"lru-cache": "^4.1.1",
"morgan": "^1.9.0",
Expand Down Expand Up @@ -77,6 +77,7 @@
"db-seed": "node scripts/db.js seed",
"db-restore": "./scripts/db-restore.sh",
"update-schema": "node scripts/update-schema.js",
"start": "node --icu-data-dir=`yarn -s run node-full-icu-path` ./server.js"
"start": "node --icu-data-dir=`yarn -s run node-full-icu-path` ./server.js",
"dev": "npm run db-migrate && npm run start"
}
}
6 changes: 1 addition & 5 deletions api/postgres-initdb.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/bin/sh -e

psql --variable=ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE DATABASE "database";
EOSQL

psql --variable=ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname=database <<-EOSQL
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE EXTENSION "uuid-ossp";
EOSQL

6 changes: 6 additions & 0 deletions api/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ type Property implements Node {
# The ID of an object
id: ID!
livingSurface: Float
landSurface: Float
numberOfRooms: Float
numberOfParkings: Int
createdAt: DateTime
updatedAt: DateTime
}
Expand Down Expand Up @@ -75,6 +78,9 @@ input PropertyFilters {
input PropertyInput {
id: ID
livingSurface: Float
landSurface: Float
numberOfRooms: Float
numberOfParkings: Int
}

type Query {
Expand Down
2 changes: 0 additions & 2 deletions api/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ if (process.env.NODE_ENV === 'production') {
// Otherwise, built it from source and launch
// on http://localhost:8080/ with "live reload"
require('source-map-support').install();
const cp = require('child_process');
const restart = require('restart');
const build = require('./scripts/build');
cp.spawnSync('docker-compose', ['up', '-d'], { stdio: 'inherit' });
build({
watch: true,
onComplete: () => restart('./build/server'),
Expand Down
7 changes: 6 additions & 1 deletion api/src/db_.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import knex from 'knex';

const db = knex({
client: 'pg',
connection: {},
connection: {
host: process.env.PG_LISTINGS_HOST,
user: process.env.PG_LISTINGS_USER,
password: process.env.PG_LISTINGS_PASSWORD,
database: process.env.PG_LISTINGS_DATABASE,
},
migrations: {
tableName: 'migrations',
},
Expand Down
Loading