Skip to content

Commit

Permalink
Node v16 Update!
Browse files Browse the repository at this point in the history
Notable Changes
- Updated to node-redis 3.1.2
- Updated to redlock 4.2.0
- Updated to okanjo-app 3.x

- Added GH actions for CI
- Removed .eslintrc.json .eslintignore .travis.yml
- RedisService.js: Updated for okanjo-app v3
- package.json:
  - Bumped to v4.0.0
  - Updated all dev dependencies to latest
  - Moved mocha, eslint configs

The node-redis package was not updated to latest due to the complete mess they made out of the module in v4.
- No longer supports Redis v4 (breaking)
- Functions now return promises (yay!)
- Configuration schema has totally changed (breaking)
- Callbacks can be re-enabled with legacyMode (cool)
- Renamed functions to pascalCase or UPPERCASE (breaking, also very not cool)

In order to upgrade to node-redis v4, the entirety of the module would need to be refactored, as would any module using redis. It would seem that another major release in the future could address this, but would come at the cost of a major redis overhaul in all affected apps.
  • Loading branch information
kfitzgerald committed Mar 21, 2022
1 parent 917d30a commit 07a94ff
Show file tree
Hide file tree
Showing 13 changed files with 5,805 additions and 92 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

29 changes: 0 additions & 29 deletions .eslintrc.json

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish Docs

on:
workflow_dispatch:
release:
types: [published]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.DOCS_KEY }}
aws-secret-access-key: ${{ secrets.DOCS_SECRET }}
aws-region: us-east-1

- name: Copy Docs
run: aws s3 cp ./README.md s3://okanjo-docs/okanjo-app-redis/ --acl public-read --content-type "text/plain; charset=utf-8" --content-encoding text
50 changes: 50 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:
runs-on: ubuntu-latest

services:
redis:
image: redis:6.2.6
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
# <port on host>:<port on container>
- 6379:6379

strategy:
fail-fast: false
matrix:
node-version: [12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- run: npm ci
- run: npm run report

- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ node_modules
.idea
*.tgz
.nyc_output
package-lock.json
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ coverage
.idea
docs
.eslint*
.travis.yml
.travis.yml
.github
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Okanjo Redis Service

[![Build Status](https://travis-ci.org/Okanjo/okanjo-app-redis.svg?branch=master)](https://travis-ci.org/Okanjo/okanjo-app-redis) [![Coverage Status](https://coveralls.io/repos/github/Okanjo/okanjo-app-redis/badge.svg?branch=master)](https://coveralls.io/github/Okanjo/okanjo-app-redis?branch=master)
[![Node.js CI](https://github.com/Okanjo/okanjo-app-redis/actions/workflows/node.js.yml/badge.svg)](https://github.com/Okanjo/okanjo-app-redis/actions/workflows/node.js.yml) [![Coverage Status](https://coveralls.io/repos/github/Okanjo/okanjo-app-redis/badge.svg?branch=master)](https://coveralls.io/github/Okanjo/okanjo-app-redis?branch=master)

Service for interfacing with Redis for the Okanjo App ecosystem.

Expand All @@ -13,6 +13,11 @@ This package:

## Breaking Changes

### 4.0
* Updated to node-redis 3.1.2
* Updated redlock to v4.2.0
* Updated to okanjo-app v3

### 3.0
* `getSet` has been renamed to `getOrSet`
* `publish` no longer takes a callback, only returns a Promise
Expand Down Expand Up @@ -546,8 +551,8 @@ Before you can run the tests, you'll need a working Redis server. We suggest usi
For example:

```bash
docker pull redis:3
docker run -d -p 6379:6379 redis:3
docker pull redis:6.2.6
docker run -d -p 6379:6379 redis:6.2.6
```

To run unit tests and code coverage:
Expand Down
13 changes: 7 additions & 6 deletions RedisService.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RedisService {
* @param config
* @param [callback]
*/
constructor(app, config, callback) {
constructor(app, config, callback=null) {
this.app = app;

this._config = config || this.app.config.redis;
Expand All @@ -37,12 +37,13 @@ class RedisService {
if (callback) callback(err); // constructor callback
});
} else {
app._serviceConnectors.push((cb) => {
this.connect((err) => {
if (callback) callback(err); // constructor callback
cb(err); // app service callback
app._serviceConnectors.push(new Promise((resolve) => {
console.log('starting redis')
this.connect(() => {
if (callback) callback(); // constructor callback
resolve();
});
});
}));
}

}
Expand Down
Loading

0 comments on commit 07a94ff

Please sign in to comment.