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

Commit c7521e9

Browse files
author
Mike Ng
committed
Initial commit of the NodeSDK.
0 parents  commit c7521e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+8104
-0
lines changed

.coveralls.yml

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

.eslintrc.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
module.exports = {
2+
"env": {
3+
"node": true
4+
},
5+
"globals": {
6+
"console": true,
7+
"exports": true,
8+
"mocha": true,
9+
"it": true,
10+
"describe": true,
11+
"before": true,
12+
"beforeEach": true,
13+
"after": true,
14+
"afterEach": true,
15+
"sinon": true
16+
},
17+
"rules": {
18+
"strict": 0,
19+
"quotes": [1, "single"],
20+
"no-native-reassign": 0,
21+
"camelcase": 0,
22+
"dot-notation": 0,
23+
"no-debugger": 1,
24+
"comma-dangle": [0, "always-multiline"],
25+
"no-underscore-dangle": 0,
26+
"no-unused-vars": [1, {"vars": "all", "args": "none"}],
27+
"no-trailing-spaces": 1,
28+
"key-spacing": 1,
29+
"no-unused-expressions": 1,
30+
"no-multi-spaces": 1,
31+
"no-use-before-define": 0,
32+
"space-infix-ops": 1,
33+
"no-console": 0,
34+
"comma-spacing": 1,
35+
"no-alert": 1,
36+
"no-empty": 1,
37+
"no-extra-bind": 1,
38+
"eol-last": 1,
39+
"eqeqeq": 1,
40+
"semi": 1,
41+
"no-multi-str": 0,
42+
"no-extra-semi": 1,
43+
"new-cap": 0,
44+
"consistent-return": 0,
45+
"no-extra-boolean-cast": 0,
46+
"no-mixed-spaces-and-tabs": 1,
47+
"no-shadow": 1,
48+
"no-sequences": 1,
49+
"handle-callback-err": 1
50+
}
51+
}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_STORE
2+
npm-debug.log
3+
node_modules
4+
5+
coverage/
6+
7+
.idea/*

.npmignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_STORE
2+
.coveralls.yml
3+
.travis.yml
4+
npm-debug.log
5+
node_modules
6+
7+
coverage/
8+
9+
.idea/*

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: node_js
2+
node_js:
3+
- "5"
4+
- "5.1"
5+
- "4"
6+
- "4.2"
7+
- "4.1"
8+
- "4.0"
9+
- "0.12"
10+
- "0.11"
11+
- "0.10"
12+
- "iojs"
13+
- "node"
14+
branches:
15+
only:
16+
- master
17+
install: "npm install"
18+
script:
19+
- "npm test"
20+
- "npm run profile-test"
21+
after_success: "npm run coveralls"

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-------------------------------------------------------------------------------
2+
0.1.0
3+
-------------------------------------------------------------------------------
4+
* Beta release of the Node SDK for server-side testing
5+
-------------------------------------------------------------------------------

CONTRIBUTING.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#Contributing to the Optimizely Node SDK
2+
3+
We welcome contributions and feedback! Please read the [README](README.md) to set up your development environment, then read the guidelines below for information on submitting your code.
4+
5+
## Development process
6+
7+
1. Create a branch off of `master`: `git checkout -b YOUR_NAME/branch_name`.
8+
2. Commit your changes. Make sure to add tests!
9+
3. Run `npm run lint` to ensure there are no lint errors.
10+
4. `git push` your changes to GitHub.
11+
5. Make sure that all unit tests are passing and that there are no merge conflicts between your branch and `master`.
12+
6. Open a pull request from `YOUR_NAME/branch_name` to `master`.
13+
7. A repository maintainer will review your pull request and, if all goes well, merge it!
14+
15+
##Pull request acceptance criteria
16+
17+
* **All code must have test coverage.** We use Mocha's chai assertion library and Sinon. Changes in functionality should have accompanying unit tests. Bug fixes should have accompanying regression tests.
18+
* Tests are located in `tests.js` files within each "module" directory.
19+
* Please don't change the `package.json` or `VERSION`. We'll take care of bumping the version when we next release.
20+
* Lint your code with our `npm run lint` before submitting.
21+
22+
##Style
23+
To enforce style rules, we use ESLint. See our [.eslintrc.js](.eslintrc.js) for more information on our specific style rules.
24+
25+
##License
26+
27+
By contributing your code, you agree to license your contribution under the terms of the [Apache License v2.0](http://www.apache.org/licenses/LICENSE-2.0). Your contributions should also include the following header:
28+
29+
```
30+
/**
31+
* Copyright 2016, Optimizely
32+
*
33+
* Licensed under the Apache License, Version 2.0 (the "License");
34+
* you may not use this file except in compliance with the License.
35+
* You may obtain a copy of the License at
36+
*
37+
* http://www.apache.org/licenses/LICENSE-2.0
38+
*
39+
* Unless required by applicable law or agreed to in writing, software
40+
* distributed under the License is distributed on an "AS IS" BASIS,
41+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42+
* See the License for the specific language governing permissions and
43+
* limitations under the License.
44+
*/
45+
```
46+
47+
##Contact
48+
If you have questions, please contact [email protected].

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2016 Optimizely
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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#Optimizely Node SDK
2+
[![Build Status](https://travis-ci.com/optimizely/node-sdk.svg?token=f1nmwFnopXzkdMKTUReK&branch=master)](https://travis-ci.com/optimizely/node-sdk)
3+
[![Coverage Status](https://coveralls.io/repos/github/optimizely/node-sdk/badge.svg?branch=master&t=pegN7y)](https://coveralls.io/github/optimizely/node-sdk?branch=master)
4+
5+
This repository houses the Node SDK for Optimizely's server-side testing product, which is currently in private beta.
6+
7+
##Getting Started
8+
9+
###Installing the SDK
10+
11+
The SDK is available through [npm](https://npmjs.com/package/optimizely-server-sdk). To install:
12+
13+
```
14+
npm install optimizely-server-sdk --save
15+
```
16+
17+
###Using the SDK
18+
See the Optimizely server-side testing [developer documentation](http://developers.optimizely.com/server/reference/index) to learn how to set up your first custom project and use the SDK. **Please note that you must be a member of the private server-side testing beta to create custom projects and use this SDK.**
19+
20+
##Development
21+
22+
###Installing dependencies
23+
24+
```npm install```
25+
26+
###Unit tests
27+
28+
You can run all unit tests with:
29+
```
30+
npm test
31+
```
32+
33+
###Benchmarking tests
34+
35+
You can run benchmarking tests with:
36+
```
37+
npm run profile-test
38+
```
39+
40+
###Contributing
41+
42+
Please see [CONTRIBUTING](CONTRIBUTING.md).

index.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
var _ = require('lodash');
2+
var configValidator = require('./lib/utils/config_validator');
3+
var defaultErrorHandler = require('./lib/plugins/error_handler');
4+
var defaultEventDispatcher = require('./lib/plugins/event_dispatcher');
5+
var enums = require('./lib/utils/enums');
6+
var logger = require('./lib/plugins/logger');
7+
var sprintf = require('sprintf');
8+
9+
var Optimizely = require('./lib/optimizely');
10+
11+
var MODULE_NAME = 'INDEX';
12+
13+
/**
14+
* Entry point into the Optimizely Node testing SDK
15+
*/
16+
module.exports = {
17+
/**
18+
* Creates an instance of the Optimizely class
19+
* @param {Object} config
20+
* @param {Object} config.datafile
21+
* @param {Object} config.errorHandler
22+
* @param {Object} config.eventDispatcher
23+
* @param {Object} config.logger
24+
* @return {Object} the Optimizely object
25+
*/
26+
createInstance: function(config) {
27+
var defaultLogger = logger.createNoOpLogger();
28+
if (config) {
29+
try {
30+
configValidator.validate(config);
31+
} catch (ex) {
32+
defaultLogger.log(enums.LOG_LEVEL.ERROR, sprintf('%s: %s', MODULE_NAME, ex.message));
33+
}
34+
}
35+
36+
config = _.assign({
37+
errorHandler: defaultErrorHandler,
38+
eventDispatcher: defaultEventDispatcher,
39+
logger: defaultLogger,
40+
}, config);
41+
42+
return new Optimizely(config);
43+
}
44+
};

0 commit comments

Comments
 (0)