From 539924d281b1ed2247af1b624295a779300e88f7 Mon Sep 17 00:00:00 2001 From: Wardormeur Date: Wed, 20 Dec 2017 10:33:08 +0000 Subject: [PATCH] Support for node 8 (#175) * Support for node 8 * Add update for lab to avoid global as a leak * Fix circle config for node 8, fix package.json to use . instead of source * Arrow functions --- .circleci/config.yml | 2 +- Dockerfile | 2 +- config/config.js | 7 ++++++- dev.Dockerfile | 2 +- package.json | 15 +++++++++------ service.js | 4 +++- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 286757c9..d2c27a61 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ jobs: build: working_directory: ~/cp-events-service docker: - - image: nodesource/node:0.10.45 + - image: node:8 environment: NODE_ENV: testing steps: diff --git a/Dockerfile b/Dockerfile index c21acb2f..db02d7d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mhart/alpine-node:0.10.48 +FROM node:8-alpine MAINTAINER butlerx ENV NODE_ENV=production ARG DEP_VERSION=latest diff --git a/config/config.js b/config/config.js index 9b3be243..3106a100 100644 --- a/config/config.js +++ b/config/config.js @@ -1,4 +1,6 @@ var path = require('path'); +var camelCase = require('camelcase'); // Lodash functions for that are stripping $ which we use for special keys +var decamelize = require('decamelize'); module.exports = function (options) { function pgConfig () { @@ -7,7 +9,10 @@ module.exports = function (options) { host: process.env.POSTGRES_HOST || '127.0.0.1', port: process.env.POSTGRES_PORT || 5432, username: process.env.POSTGRES_USERNAME, - password: process.env.POSTGRES_PASSWORD + password: process.env.POSTGRES_PASSWORD, + nolimit: true, + fromColumnName: (attr) => camelCase(attr), + toColumnName: (attr) => decamelize(attr) }; } function kueConfig () { diff --git a/dev.Dockerfile b/dev.Dockerfile index 13e122e7..ab66d0b7 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -1,4 +1,4 @@ -FROM mhart/alpine-node:0.10.48 +FROM node:8-alpine MAINTAINER butlerx ENV NODE_ENV=development RUN apk add --update git build-base python postgresql-client && \ diff --git a/package.json b/package.json index 24f61c9c..7075afcf 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "lint": "semistandard *.js config/config.js", "testdata": "node test/lib/service.js", - "test": "sh -c 'source ./config/development.env; npm run lint && lab lib/controllers -P spec --ignore __core-js_shared__ '", - "coverage": "sh -c 'source ./config/development.env; lab --threshold 68 -r html -o ./coverage/coverage.html -r lcov -o ./coverage/lcov.info -r json -o ./coverage/coverage.json -r console -o stdout'", + "test": "sh -c '. ./config/development.env; npm run lint && lab lib/controllers -P spec --ignore __core-js_shared__ '", + "coverage": "sh -c '. ./config/development.env; lab --threshold 68 -r html -o ./coverage/coverage.html -r lcov -o ./coverage/lcov.info -r json -o ./coverage/coverage.json -r console -o stdout'", "start": "node service.js", "dev": "nodemon service.js" }, @@ -25,7 +25,7 @@ }, "devDependencies": { "chai": "^4.0", - "lab": "5.15.2", + "lab": "14.x", "nodemon": "1.11.0", "pre-commit": "1.1.2", "semistandard": "7.0.3", @@ -45,12 +45,15 @@ "lodash": "3.7.0", "moment": "2.10.3", "newrelic": "1.21.1", - "pg": "4.4.0", - "postgrator": "2.5.0", + "camelcase": "^4.1.0", + "decamelize": "^1.2.0", + "pg": "5.1.0", + "postgrator": "2.8.1", "sanitize-html": "1.14.1", "seneca": "1.4.0", "seneca-kue": "git://github.com/wardormeur/seneca-kue.git", - "seneca-postgresql-store": "1.1.3", + "seneca-postgresql-store": "2.3", + "seneca-store-query": "0.0.5", "seneca-queue": "^0.3.0", "shortid": "2.2.2", "utils": "^0.3.1", diff --git a/service.js b/service.js index d035ab5a..5b9cbc31 100644 --- a/service.js +++ b/service.js @@ -9,6 +9,7 @@ var seneca = require('seneca')(config); var util = require('util'); var _ = require('lodash'); var store = require('seneca-postgresql-store'); +var storeQuery = require('seneca-store-query'); var dgram = require('dgram'); var service = 'cp-events-service'; var sanitizeHtml = require('sanitize-html'); @@ -41,6 +42,7 @@ seneca.options.sanitizeTextArea = { }; seneca.decorate('customValidatorLogFormatter', require('./lib/custom-validator-log-formatter')); seneca.use(store, config['postgresql-store']); +seneca.use(storeQuery); seneca.use(require('./lib/cd-events'), { logger: log.logger }); seneca.use(require('cp-permissions-plugin'), { config: __dirname + '/config/permissions' @@ -90,7 +92,7 @@ require('./migrate-psql-db.js')(function (err) { client.close(); }); - var escape = require('seneca-postgresql-store/lib/relational-util').escapeStr; + var escape = require('seneca-store-query/lib/relational-util').escapeStr; ['load', 'list'].forEach(function (cmd) { seneca.wrap('role: entity, cmd: ' + cmd, function filterFields (args, cb) { try {