Skip to content

Commit f0a05e1

Browse files
committed
initial commit
0 parents  commit f0a05e1

File tree

6 files changed

+78
-0
lines changed

6 files changed

+78
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

LICENSE.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2016 Catamorphic, Co.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### LaunchDarkly Sample TypeScript Node.js Application ###
2+
We've built a simple console application that demonstrates how LaunchDarkly's SDK works. Below, you'll find the basic build procedure, but for more comprehensive instructions, you can visit your [Quickstart page](https://app.launchdarkly.com/quickstart#/).
3+
4+
##### Build instructions #####
5+
1. Install the LaunchDarkly Node.js SDK by running `npm install`
6+
2. Copy your API key and feature flag key from your LaunchDarkly dashboard into `index.ts`
7+
3. Run `npm start`

index.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as LaunchDarkly from 'ldclient-node';
2+
3+
// TODO : Enter your LaunchDarkly SDK key here
4+
const client = LaunchDarkly.init("YOUR_SDK_KEY");
5+
6+
const user = {
7+
"firstName":"Bob",
8+
"lastName":"Loblaw",
9+
"key":"louise@example.com",
10+
"custom":{
11+
"groups":"beta_testers"
12+
}
13+
};
14+
15+
client.once('ready', function() {
16+
// TODO : Enter the key for your feature flag here
17+
client.variation("enable-pinning", user, false, function(err, showFeature) {
18+
client.track("event-called", user);
19+
if (showFeature) {
20+
// application code to show the feature
21+
console.log("Showing your feature to " + user.key );
22+
} else {
23+
// the code to run if the feature is off
24+
console.log("Not showing your feature to " + user.key);
25+
}
26+
client.flush(function() {
27+
client.close();
28+
});
29+
});
30+
});

package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "hello-node-typescript",
3+
"version": "1.0.0",
4+
"description": "Hello LaunchDarkly for Node.js with TypeScript",
5+
"main": "index.ts",
6+
"scripts": {
7+
"start": "npm run build:live",
8+
"build:live": "nodemon --exec ./node_modules/.bin/ts-node -- ./index.ts"
9+
},
10+
"author": "LaunchDarkly <team@launchdarkly.com>",
11+
"license": "Apache-2.0",
12+
"devDependencies": {
13+
"@types/node": "8.0.4",
14+
"nodemon": "1.11.0",
15+
"ts-node": "3.1.0",
16+
"typescript": "2.4.1"
17+
},
18+
"dependencies": {
19+
"ldclient-node": "3.0.14"
20+
}
21+
}

tsconfig.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"strict": true
5+
}
6+
}

0 commit comments

Comments
 (0)