Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit fba1b7a

Browse files
committed
Merge branch '3.0'
2 parents 1dcb376 + 95df460 commit fba1b7a

File tree

8 files changed

+135
-65
lines changed

8 files changed

+135
-65
lines changed

.circleci/config.yml

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,58 @@
1-
version: 2
1+
version: 2.1
22

33
workflows:
4-
version: 2
5-
test:
4+
build-and-test-all:
65
jobs:
7-
- oldest-long-term-support-release
8-
- current-release
9-
10-
node-template: &node-template
11-
steps:
12-
- checkout
13-
- run: echo "Node version:" `node --version`
14-
- run: npm install
15-
- run: npm run lint
16-
- run:
17-
command: npm test
18-
environment:
19-
JEST_JUNIT_OUTPUT: "reports/junit/js-test-results.xml"
20-
- store_test_results:
21-
path: reports/junit
22-
- run: npm run check-typescript
23-
- store_artifacts:
24-
path: reports/junit
6+
# CircleCI's current generation of Node images, cimg/node, allow you to leave the
7+
# patch version unpinned, but require you to specify the minor version. The one
8+
# exception is cimg/node:current, which will always give us the latest release in
9+
# the latest major version-- and the latest major version is where it's most likely
10+
# that there would be a new minor version, anyway.
11+
- build-test-linux:
12+
name: latest Node version
13+
docker-image: cimg/node:current
14+
run-lint: true
15+
- build-test-linux:
16+
name: Node 16.3
17+
docker-image: cimg/node:16.3
18+
- build-test-linux:
19+
name: Node 15.14
20+
docker-image: cimg/node:15.14
21+
- build-test-linux:
22+
name: Node 14.17
23+
docker-image: cimg/node:14.17
24+
- build-test-linux:
25+
name: Node 13.14
26+
docker-image: cimg/node:13.14
27+
- build-test-linux:
28+
name: Node 12.22
29+
docker-image: cimg/node:12.22
2530

2631
jobs:
27-
oldest-long-term-support-release:
28-
<<: *node-template
29-
docker:
30-
- image: circleci/node:6
31-
- image: amazon/dynamodb-local
32-
33-
current-release:
34-
<<: *node-template
32+
build-test-linux:
33+
parameters:
34+
run-lint:
35+
type: boolean
36+
default: false
37+
docker-image:
38+
type: string
3539
docker:
36-
- image: circleci/node:latest
40+
- image: <<parameters.docker-image>>
3741
- image: amazon/dynamodb-local
42+
steps:
43+
- checkout
44+
- run: echo "Node version:" `node --version`
45+
- run: npm install
46+
- run:
47+
command: npm test
48+
environment:
49+
JEST_JUNIT_OUTPUT: "reports/junit/js-test-results.xml"
50+
- run: npm run check-typescript
51+
- when:
52+
condition: <<parameters.run-lint>>
53+
steps:
54+
- run: npm run lint
55+
- store_test_results:
56+
path: reports/junit
57+
- store_artifacts:
58+
path: reports/junit

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
node_modules/
2+
test-types.js
3+
.eslintrc.js

CONTRIBUTING.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Contributing to this library
2+
3+
The source code for this library is [here](https://github.com/launchdarkly/node-server-sdk-dynamodb). We encourage pull-requests and other contributions from the community. Since this library is meant to be used in conjunction with the LaunchDarkly Server-Side Node.js SDK, you may want to look at the [SDK source code](https://github.com/launchdarkly/node-server-sdk) and our [SDK contributor's guide](http://docs.launchdarkly.com/docs/sdk-contributors-guide).
4+
5+
## Submitting bug reports and feature requests
6+
7+
The LaunchDarkly SDK team monitors the [issue tracker](https://github.com/launchdarkly/node-server-sdk-dynamodb/issues) in this repository. Bug reports and feature requests specific to this project should be filed in the issue tracker. The SDK team will respond to all newly filed issues within two business days.
8+
9+
## Submitting pull requests
10+
11+
We encourage pull requests and other contributions from the community. Before submitting pull requests, ensure that all temporary or unintended code is removed. Don't worry about adding reviewers to the pull request; the LaunchDarkly SDK team will add themselves. The SDK team will acknowledge all pull requests within two business days.
12+
13+
## Build instructions
14+
15+
### Prerequisites
16+
17+
The project uses `npm`, which is bundled in all supported versions of Node. It should be built against the lowest compatible version, Node 12.
18+
19+
### Setup
20+
21+
To install project dependencies, from the project root directory:
22+
23+
```
24+
npm install
25+
```
26+
27+
### Testing
28+
29+
To run all unit tests:
30+
31+
```
32+
npm test
33+
```
34+
35+
The tests expect you to have DynamoDB running locally on the default port, 6379. One way to do this is with Docker:
36+
37+
```bash
38+
docker run -p 8000:8000 amazon/dynamodb-local
39+
```
40+
41+
To verify that the TypeScript declarations compile correctly (this involves compiling the file `test-types.ts`, so if you have changed any types or interfaces, you will want to update that code):
42+
43+
```
44+
npm run check-typescript
45+
```

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
This library provides a DynamoDB-backed persistence mechanism (feature store) for the [LaunchDarkly Node.js SDK](https://github.com/launchdarkly/node-server-sdk), replacing the default in-memory feature store. It uses the AWS SDK for Node.js.
66

7-
The minimum version of the LaunchDarkly Node.js SDK for use with this library is 5.8.1.
7+
The minimum version of the LaunchDarkly Node.js SDK for use with this library is 6.0.0.
88

9-
For more information, see also: [Using a persistent feature store](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store).
9+
For more information, see the [SDK features guide](https://docs.launchdarkly.com/sdk/features/database-integrations).
1010

1111
TypeScript API documentation is [here](https://launchdarkly.github.io/node-server-sdk-dynamodb).
1212

dynamodb_feature_store.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var AWS = require('aws-sdk');
2-
var winston = require('winston');
32

43
var helpers = require('./dynamodb_helpers');
54
var CachingStoreWrapper = require('launchdarkly-node-server-sdk/caching_store_wrapper');
@@ -11,19 +10,17 @@ function DynamoDBFeatureStore(tableName, options) {
1110
if (ttl === null || ttl === undefined) {
1211
ttl = defaultCacheTTLSeconds;
1312
}
14-
return new CachingStoreWrapper(dynamoDBFeatureStoreInternal(tableName, options), ttl, 'DynamoDB');
13+
return config =>
14+
new CachingStoreWrapper(
15+
dynamoDBFeatureStoreInternal(tableName, options, config.logger),
16+
ttl,
17+
'DynamoDB'
18+
);
1519
}
1620

17-
function dynamoDBFeatureStoreInternal(tableName, options) {
21+
function dynamoDBFeatureStoreInternal(tableName, options, sdkLogger) {
1822
options = options || {};
19-
var logger = (options.logger ||
20-
new winston.Logger({
21-
level: 'info',
22-
transports: [
23-
new (winston.transports.Console)(),
24-
]
25-
})
26-
);
23+
var logger = options.logger || sdkLogger;
2724
var dynamoDBClient = options.dynamoDBClient || new AWS.DynamoDB.DocumentClient(options.clientOptions);
2825
var prefix = options.prefix || '';
2926

index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
/**
44
* Interface for the DynamoDB feature store component to be used with the LaunchDarkly SDK.
55
*
6-
* See: https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store
6+
* See: https://docs.launchdarkly.com/sdk/features/database-integrations
77
*/
88

99
declare module 'launchdarkly-node-server-sdk-dynamodb' {
10-
import { LDFeatureStore, LDLogger } from 'launchdarkly-node-server-sdk';
10+
import { LDFeatureStore, LDLogger, LDOptions } from 'launchdarkly-node-server-sdk';
1111
import { DynamoDB } from 'aws-sdk';
1212

1313
/**
@@ -23,7 +23,7 @@ declare module 'launchdarkly-node-server-sdk-dynamodb' {
2323
* Options for configuring the feature store.
2424
*/
2525
options?: LDDynamoDBOptions
26-
): LDFeatureStore;
26+
): (config: LDOptions) => LDFeatureStore;
2727

2828
/**
2929
* Options for configuring a DynamoDBFeatureStore.
@@ -56,7 +56,7 @@ declare module 'launchdarkly-node-server-sdk-dynamodb' {
5656

5757
/**
5858
* A logger to be used for warnings and errors generated by the feature store. If not specified,
59-
* the default is an instance of winston.Logger.
59+
* it will use the SDK's logging configuration.
6060
*/
6161
logger?: LDLogger;
6262
}

package.json

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,21 @@
1111
},
1212
"types": "./index.d.ts",
1313
"devDependencies": {
14-
"@babel/core": "7.4.3",
15-
"@babel/preset-env": "7.4.3",
14+
"@babel/core": "^7.14.6",
15+
"@babel/preset-env": "^7.14.5",
16+
"@types/node": "^15.12.2",
1617
"aws-sdk": "^2.349.0",
17-
"babel-jest": "24.7.1",
18-
"eslint": "5.8.0",
19-
"eslint-formatter-pretty": "1.3.0",
20-
"jest": "24.7.1",
21-
"jest-junit": "6.3.0",
22-
"launchdarkly-js-test-helpers": "^1.0.0",
23-
"launchdarkly-node-server-sdk": ">= 5.8.1",
24-
"typescript": "^3.8.3"
18+
"babel-jest": "^27.0.2",
19+
"eslint": "^7.28.0",
20+
"eslint-config-prettier": "^8.3.0",
21+
"eslint-formatter-pretty": "^4.1.0",
22+
"eslint-plugin-prettier": "^3.4.0",
23+
"jest": "^27.0.4",
24+
"jest-junit": "^12.2.0",
25+
"launchdarkly-js-test-helpers": "^1.2.1",
26+
"launchdarkly-node-server-sdk": "^6.0.0-rc.1",
27+
"prettier": "^2.3.1",
28+
"typescript": "^4.3.2"
2529
},
2630
"jest": {
2731
"rootDir": ".",
@@ -33,15 +37,14 @@
3337
"transformIgnorePatterns": []
3438
},
3539
"dependencies": {
36-
"node-cache": "4.2.0",
37-
"winston": "2.4.1"
40+
"node-cache": "4.2.0"
3841
},
3942
"peerDependencies": {
4043
"aws-sdk": "^2.349.0",
41-
"launchdarkly-node-server-sdk": ">= 5.8.1"
44+
"launchdarkly-node-server-sdk": "^6.0.0-rc.1"
4245
},
4346
"engines": {
44-
"node": ">= 0.8.x"
47+
"node": ">= 12.0"
4548
},
4649
"bugs": {
4750
"url": "https://github.com/launchdarkly/node-server-sdk-dynamodb/issues"

tests/dynamodb_feature_store-test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ describe('DynamoDBFeatureStore', function() {
2525

2626
var table = 'test-store';
2727

28+
const sdkConfig = { logger: stubLogger() };
29+
2830
beforeAll(function(done) {
2931
dynamodb.describeTable({ TableName: table }, function(err) {
3032
if (!err) {
@@ -93,15 +95,15 @@ describe('DynamoDBFeatureStore', function() {
9395
}
9496

9597
function makeStore() {
96-
return new DynamoDBFeatureStore(table);
98+
return DynamoDBFeatureStore(table)(sdkConfig);
9799
}
98100

99101
function makeStoreWithoutCache() {
100-
return new DynamoDBFeatureStore(table, {cacheTTL: 0});
102+
return DynamoDBFeatureStore(table, {cacheTTL: 0})(sdkConfig);
101103
}
102104

103105
function makeStoreWithPrefix(prefix) {
104-
return new DynamoDBFeatureStore(table, {prefix: prefix, cacheTTL: 0});
106+
return DynamoDBFeatureStore(table, {prefix: prefix, cacheTTL: 0})(sdkConfig);
105107
}
106108

107109
function makeStoreWithDefaultPrefix() {
@@ -139,7 +141,7 @@ describe('DynamoDBFeatureStore', function() {
139141
beforeEach(() => {
140142
client = {};
141143
logger = stubLogger();
142-
store = new DynamoDBFeatureStore(table, { dynamoDBClient: client, logger: logger });
144+
store = DynamoDBFeatureStore(table, { dynamoDBClient: client })({ logger });
143145
});
144146

145147
it('error from query in init', done => {

0 commit comments

Comments
 (0)