From c7364a4e0436376629a2232e54761964953c5d51 Mon Sep 17 00:00:00 2001 From: Wardormeur Date: Wed, 20 Dec 2017 11:00:42 +0000 Subject: [PATCH] Support for node 8 (#282) * Support for node 8 * Arrow function --- .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 3f53e98d..ff373bba 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ jobs: build: working_directory: ~/cp-users-service docker: - - image: nodesource/node:0.10.45 + - image: node:8 environment: NODE_ENV: testing steps: diff --git a/Dockerfile b/Dockerfile index 916a3304..9f991fc4 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 1478b725..c5c08de7 100644 --- a/config/config.js +++ b/config/config.js @@ -1,5 +1,7 @@ 'use strict'; var path = require('path'); +var camelCase = require('camelcase'); // Lodash functions for that are stripping $ which we use for special keys +var decamelize = require('decamelize'); var CpTranslations = require('cp-translations'); module.exports = function (options) { @@ -9,7 +11,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) }; } diff --git a/dev.Dockerfile b/dev.Dockerfile index 2ab79537..fcfb85a9 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 63c20ced..df236464 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "test": "test" }, "scripts": { - "test": "npm run lint && bash -c 'source ./config/development.env; ./node_modules/.bin/lab --ignore __core-js_shared__ --flat --threshold 50 -r html -o ./coverage/coverage.html -r lcov -o ./coverage/lcov.info -r json -o ./coverage/coverage.json -r lab-quieter-reporter -o stdout -m 5000'", + "test": "npm run lint && sh -c '. ./config/development.env; ./node_modules/.bin/lab --ignore __core-js_shared__ --flat --threshold 50 -r html -o ./coverage/coverage.html -r lcov -o ./coverage/lcov.info -r json -o ./coverage/coverage.json -r lab-quieter-reporter -o stdout -m 5000'", "testdata": "node test/lib/service.js", "covrep": "bash test/covrep.sh", "lint": "./node_modules/.bin/semistandard *.js config/config.js", @@ -28,11 +28,13 @@ }, "dependencies": { "async": "0.9.0", + "camelcase": "^4.1.0", "cp-i18n-lib": "git+https://github.com/CoderDojo/cp-i18n-lib.git", "cp-logs-lib": "git://github.com/CoderDojo/cp-logs-lib#1.1.0", "cp-permissions-plugin": "git://github.com/CoderDojo/cp-permissions-plugin#1.0.4", "cp-translations": "^1.0.4", "cuid": "1.2.5", + "decamelize": "^1.2.0", "ejs": "1.0.0", "jed": "1.1.0", "js-yaml": "3.2.7", @@ -42,15 +44,16 @@ "newrelic": "1.19.2", "node-uuid": "1.4.3", "optimist": "0.6.1", - "pg": "4.4.0", + "pg": "5.1.0", "pg-large-object": "0.0.1", "po2json": "0.4.2", - "postgrator": "2.2.0", + "postgrator": "2.8.1", "request": "2.58.0", "seneca": "1.4", "seneca-auth": "1.0", - "seneca-mail": "0.2.1", - "seneca-postgresql-store": "1.1.3", + "seneca-mail": "^0.2.2", + "seneca-postgresql-store": "2.3", + "seneca-store-query": "0.0.5", "seneca-user": "1.0", "shortid": "2.2.2", "util": "^0.10.3", @@ -58,7 +61,7 @@ }, "devDependencies": { "chai": "2.2.0", - "lab": "5.15.1", + "lab": "14.x", "lab-quieter-reporter": "1.0.1", "nodemon": "1.11.0", "pre-commit": "1.1.2", diff --git a/service.js b/service.js index b7fd72e3..9136f3c5 100644 --- a/service.js +++ b/service.js @@ -8,6 +8,7 @@ var config = require('./config/config.js')(); var seneca = require('seneca')(config); var _ = require('lodash'); var store = require('seneca-postgresql-store'); +var storeQuery = require('seneca-store-query'); var service = 'cp-users-service'; var log = require('cp-logs-lib')({name: service, level: 'warn'}); config.log = log.log; @@ -21,6 +22,7 @@ if (process.env.NODE_ENV !== 'production') { seneca.options(config); seneca.decorate('customValidatorLogFormatter', require('./lib/custom-validator-log-formatter')); seneca.use(store, config['postgresql-store']); +seneca.use(storeQuery); if (process.env.MAILTRAP_ENABLED === 'true') { seneca.use('mail', config.mailtrap); } else { @@ -89,7 +91,7 @@ require('./migrate-psql-db.js')(function (err) { client.close(); }); - var escape = require('seneca-postgresql-store/lib/relational-util').escapeStr; + var escape = require('seneca-standard-query/lib/relational-util').escapeStr; ['load', 'list'].forEach(function (cmd) { seneca.wrap('role: entity, cmd: ' + cmd, function filterFields (args, cb) { try {