-
Notifications
You must be signed in to change notification settings - Fork 31
#1 Layout an initial repository for create a typescript server sdk. #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0f000eb
f7a3c68
82758cb
48a6d60
dca048a
b6f2151
851bbba
7353f73
c693e20
2b1e7e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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: { | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package-lock.json | ||
| dist/ | ||
| node_modules/ | ||
| **/*.tsbuildinfo |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Contributing to the LaunchDarkly Server-Side SDK for Node.js | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've left the contributing and readme as node specific for now. |
||
|
|
||
| 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. | ||
| 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. |
| 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. | ||
|
|
||
| [](https://www.npmjs.com/package/launchdarkly-node-server-sdk) | ||
| [](https://circleci.com/gh/launchdarkly/node-server-sdk) | ||
| [](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! | ||
|
|
||
| [](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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a workspace package.json. Which allows sharing dependencies, dependencies between packages in this repository, and for everything to be built at the top level. |
||
| "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" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "name": "@launchdarkly/js-server-sdk-platform-node", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've used organization prefixes for these names, but we can change them to whatever we want before we publish them.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the application teams have been using |
||
| "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" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import doesItWork from '@launchdarkly/js-server-sdk-common'; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The index files just contain some code to make sure things are linking together correctly. |
||
|
|
||
| doesItWork(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a good starting point, but we may want to change things for compatibility as we work through things. This should be good for node. |
||
| "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 | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "extends": "./tsconfig.json", | ||
| "include": ["src/**/*"], | ||
| "compilerOptions": { | ||
| "composite": true, | ||
| }, | ||
| } |
| 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" | ||
| } | ||
| } |
| 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 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "extends": "./tsconfig.json", | ||
| "include": ["src/**/*"], | ||
| "compilerOptions": { | ||
| "composite": true, | ||
| }, | ||
| } |
| 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" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function doesItWork() { | ||
| console.log('yes'); | ||
| } |
| 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 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "extends": "./tsconfig.json", | ||
| "include": ["src/**/*"], | ||
| "compilerOptions": { | ||
| "composite": true, | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file exists so the linter can lint all the TS. Otherwise it will get confused about TS files outside the 'project'. |
||
| "extends": "./tsconfig.json", | ||
| "include": ["/**/*.ts"], | ||
| "exclude": ["node_modules"] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This references the other tsconfigs and allows building the entire project at once. Each project will have its own 'dist' output. |
||
| "files": [], | ||
| "references": [ | ||
| { | ||
| "path": "./sdk-common/tsconfig.ref.json" | ||
| }, | ||
| { | ||
| "path": "./server-sdk-common/tsconfig.ref.json" | ||
| }, | ||
| { | ||
| "path": "./platform-node/tsconfig.ref.json" | ||
| }, | ||
| ], | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used the airbnb style as the base. It is very popular and so will produce a style very familiar to many developers.