-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
13bf23c
commit b043331
Showing
20 changed files
with
340 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = { | ||
env: { | ||
node: true, | ||
}, | ||
extends: [ | ||
'airbnb-base', | ||
'airbnb-typescript/base' | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: './tsconfig.eslint.json' | ||
}, | ||
plugins: [ | ||
'@typescript-eslint', | ||
], | ||
ignorePatterns: ["**/dist/**"], | ||
rules: { | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package-lock.json | ||
dist/ | ||
node_modules/ | ||
**/*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Contributing to the LaunchDarkly Server-Side SDK for Node.js | ||
|
||
LaunchDarkly has published an [SDK contributor's guide](https://docs.launchdarkly.com/sdk/concepts/contributors-guide) that provides a detailed explanation of how our SDKs work. See below for additional information on how to contribute to this SDK. | ||
|
||
## Submitting bug reports and feature requests | ||
|
||
The LaunchDarkly SDK team monitors the [issue tracker](https://github.com/launchdarkly/node-server-sdk/issues) in the SDK repository. Bug reports and feature requests specific to this SDK should be filed in this issue tracker. The SDK team will respond to all newly filed issues within two business days. | ||
|
||
## Submitting pull requests | ||
|
||
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. | ||
|
||
## Build instructions | ||
|
||
### Prerequisites | ||
|
||
The project should be built and tested against the lowest compatible version, Node 12. It uses `npm`, which is bundled in all supported versions of Node. | ||
|
||
### Setup | ||
|
||
To install project dependencies, from the project root directory: | ||
|
||
``` | ||
npm install | ||
``` | ||
|
||
### Testing | ||
|
||
To run all unit tests: | ||
|
||
``` | ||
npm test | ||
``` | ||
|
||
To run the SDK contract test suite (see [`contract-tests/README.md`](./contract-tests/README.md)): | ||
|
||
```bash | ||
npm run contract-tests | ||
``` | ||
|
||
### Auditing package dependencies | ||
|
||
The `npm audit` tool compares all dependencies and transitive dependencies to a database of package versions with known vulnerabilities. However, the output of this tool includes both runtime and development dependencies. | ||
|
||
Runtime dependencies can affect applications using the SDK; they can only be fixed by updating one of the explicit dependencies in `package.json`. Development dependencies cannot affect applications, but will still cause `npm audit` to flag the project; they can be fixed by running `npm audit fix` to add overrides for transitive dependencies in `package-lock.json`. | ||
|
||
It is important _not_ to run `npm audit fix` if there are any bad _runtime_ dependencies, because it will hide the problem in our own build, without actually fixing the vulnerability when an application uses the SDK. | ||
|
||
The script `scripts/better-audit.sh`, which is run in the CI build and can also be run manually, processes the output of `npm audit` to eliminate all duplicate entries and then determines whether each entry is coming from a runtime dependency or a development dependency. If there are any runtime ones, it terminates with an error code so the build will fail. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2022 Catamorphic, Co. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# LaunchDarkly Server-Side SDK for JavaScript | ||
|
||
<!-- | ||
These will need updated. Likely the NPM packge for node will be the same. | ||
[![NPM](https://img.shields.io/npm/v/launchdarkly-node-server-sdk.svg?style=flat-square)](https://www.npmjs.com/package/launchdarkly-node-server-sdk) | ||
[![CircleCI](https://circleci.com/gh/launchdarkly/node-server-sdk.svg?style=svg)](https://circleci.com/gh/launchdarkly/node-server-sdk) | ||
[![Documentation](https://img.shields.io/static/v1?label=GitHub+Pages&message=API+reference&color=00add8)](https://launchdarkly.github.io/node-server-sdk) --> | ||
|
||
The LaunchDarkly Server-Side SDK for Node.js is designed primarily for use in multi-user systems such as web servers and applications. It follows the server-side LaunchDarkly model for multi-user contexts. It is not intended for use in desktop and embedded systems applications. | ||
|
||
For using LaunchDarkly in *client-side* Node.js applications, refer to our [Client-side Node.js SDK](https://github.com/launchdarkly/node-client-sdk). | ||
|
||
## LaunchDarkly overview | ||
|
||
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today! | ||
|
||
[![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly) | ||
|
||
## Supported Node versions | ||
|
||
This version of the LaunchDarkly SDK is compatible with Node.js versions 12 and above. | ||
|
||
## Getting started | ||
|
||
Refer to the [SDK reference guide](https://docs.launchdarkly.com/sdk/server-side/node-js) for instructions on getting started with using the SDK. | ||
|
||
## Learn more | ||
|
||
Check out our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/server-side/node-js). | ||
|
||
The authoritative description of all properties and methods is in the [TypeScript documentation](https://launchdarkly.github.io/node-server-sdk/). | ||
|
||
## Testing | ||
|
||
We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs, as well as test networking behavior in a long-running application. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly. | ||
|
||
## Contributing | ||
|
||
We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this SDK. | ||
|
||
## About LaunchDarkly | ||
|
||
* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can: | ||
* Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases. | ||
* Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?). | ||
* Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file. | ||
* Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline. | ||
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/sdk) for a complete list. | ||
* Explore LaunchDarkly | ||
* [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information | ||
* [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides | ||
* [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation | ||
* [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "@launchdarkly/js-server-sdk", | ||
"workspaces": [ | ||
"sdk-common", | ||
"server-sdk-common", | ||
"platform-node" | ||
], | ||
"scripts": { | ||
"clean": "tsc --build --clean", | ||
"build": "tsc --build", | ||
"lint": "eslint . --ext .ts", | ||
"lint:fix": "npm run lint -- --fix" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.22.0", | ||
"@typescript-eslint/parser": "^5.22.0", | ||
"eslint": "^8.14.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-airbnb-typescript": "^17.0.0", | ||
"eslint-plugin-import": "^2.26.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "@launchdarkly/js-server-sdk-platform-node", | ||
"version": "1.0.0", | ||
"description": "Node platform for the JS Server SDK", | ||
"type": "commonjs", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"keywords": [ | ||
"launchdarkly", | ||
"analytics", | ||
"client" | ||
], | ||
"scripts": { | ||
"test": "jest --ci", | ||
"build": "tsc" | ||
}, | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@launchdarkly/js-server-sdk-common": "@launchdarkly/js-server-sdk-common" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^27.4.1", | ||
"jest": "^27.5.1", | ||
"ts-jest": "^27.1.4", | ||
"typescript": "^4.6.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import doesItWork from '@launchdarkly/js-server-sdk-common'; | ||
|
||
doesItWork(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "dist", | ||
"target": "es6", | ||
"lib": [ | ||
"es6" | ||
], | ||
"module": "commonjs", | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
// Needed for CommonJS modules: markdown-it, fs-extra | ||
"allowSyntheticDefaultImports": true, | ||
"sourceMap": true, | ||
"declaration": true, | ||
"declarationMap": true, // enables importers to jump to source | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["src/**/*"], | ||
"compilerOptions": { | ||
"composite": true, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "@launchdarkly/js-sdk-common", | ||
"type": "commonjs", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"description": "LaunchDarkly SDK for JavaScript - common code", | ||
"files": [ | ||
"/dist" | ||
], | ||
"keywords": [ | ||
"launchdarkly", | ||
"analytics", | ||
"client" | ||
], | ||
"scripts": { | ||
"test": "jest --ci", | ||
"build": "tsc" | ||
}, | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"@types/jest": "^27.4.1", | ||
"jest": "^27.5.1", | ||
"ts-jest": "^27.1.4", | ||
"typescript": "^4.6.3" | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "dist", | ||
"target": "es6", | ||
"lib": [ | ||
"es6", | ||
], | ||
"module": "commonjs", | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
// Needed for CommonJS modules: markdown-it, fs-extra | ||
"allowSyntheticDefaultImports": true, | ||
"sourceMap": true, | ||
"declaration": true, | ||
"declarationMap": true, // enables importers to jump to source | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["src/**/*"], | ||
"compilerOptions": { | ||
"composite": true, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "@launchdarkly/js-server-sdk-common", | ||
"type": "commonjs", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"description": "LaunchDarkly Server SDK for JavaScript - common code", | ||
"files": [ | ||
"/dist" | ||
], | ||
"keywords": [ | ||
"launchdarkly", | ||
"analytics", | ||
"client" | ||
], | ||
"scripts": { | ||
"test": "jest --ci", | ||
"build": "tsc" | ||
}, | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"@types/jest": "^27.4.1", | ||
"jest": "^27.5.1", | ||
"ts-jest": "^27.1.4", | ||
"typescript": "^4.6.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function doesItWork() { | ||
console.log('yes'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "dist", | ||
"target": "es6", | ||
"lib": [ | ||
"es6", | ||
], | ||
"module": "commonjs", | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
// Needed for CommonJS modules: markdown-it, fs-extra | ||
"allowSyntheticDefaultImports": true, | ||
"sourceMap": true, | ||
"declaration": true, | ||
"declarationMap": true, // enables importers to jump to source | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["src/**/*"], | ||
"compilerOptions": { | ||
"composite": true, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"files": [], | ||
"references": [ | ||
{ | ||
"path": "./sdk-common/tsconfig.ref.json" | ||
}, | ||
{ | ||
"path": "./server-sdk-common/tsconfig.ref.json" | ||
}, | ||
{ | ||
"path": "./platform-node/tsconfig.ref.json" | ||
}, | ||
], | ||
} |