Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json
9 changes: 9 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
bracketSpacing: true,
printWidth: 100,
singleQuote: true,
tabWidth: 4,
trailingComma: 'none',
useTabs: false,
arrowParens: 'avoid'
};
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Contributing

We're always looking to improve this project, open source contribution is encouraged so long as they adhere to our guidelines.

# Pull Requests
Expand All @@ -7,7 +8,7 @@ The Solid State team will be monitoring for pull requests. When we get one, a me

**A couple things to keep in mind:**

- If you've changed APIs, update the documentation.
- Keep the code style (indents, wrapping) consistent.
- If your PR involves a lot of commits, squash them using ```git rebase -i``` as this makes it easier for us to review.
- Keep lines under 80 characters.
- If you've changed APIs, update the documentation.
- Keep the code style (indents, wrapping) consistent.
- If your PR involves a lot of commits, squash them using `git rebase -i` as this makes it easier for us to review.
- Keep lines under 80 characters.
2 changes: 1 addition & 1 deletion LICENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Redistribution and use in source and binary forms, with or without modification,

3. Neither the name of the Sentry nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20 changes: 10 additions & 10 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Flagsmith example
==================================
# Flagsmith example


Getting Started
---------------
## Getting Started

# Setup via cli

```npm i ssg-node -g```
`npm i ssg-node -g`

```ssg-node PROJECT_NAME```
`ssg-node PROJECT_NAME`

# Run
```$ npm start```

`$ npm start`

# Nodemon (Restart server on changes)
```npm run dev```

`npm run dev`

# The project
- ``/server/api`` contains a simple express api that interacts with Flagsmith

- `/server/api` contains a simple express api that interacts with Flagsmith
24 changes: 12 additions & 12 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"npm": "3.10.x"
},
"dependencies": {
"flagsmith-nodejs": "^1.0.8",
"node-cache": "^5.1.2",
"ssg-node-express": "4.16.4",
"ssg-util": "0.0.3"
},
Expand Down
33 changes: 16 additions & 17 deletions example/server/api/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
const Router = require('express').Router;
const environmentID = "uCDQzKWgejrutqSYYsKWen";
const flagsmith = require("flagsmith-nodejs");
const environmentID = 'uCDQzKWgejrutqSYYsKWen';
const flagsmith = require('../../../');
const NodeCache = require('node-cache');

flagsmith.init({
environmentID
// this is an example of a user-defined cache
/*cache: new NodeCache({
stdTTL: 5
})*/
});

module.exports = () => {
const api = Router();

api.get('/', (req, res) => {
flagsmith.getValue("font_size")
.then((font_size) => {
res.json({font_size})
});
api.get('/', async (req, res) => {
const font_size = await flagsmith.getValue('font_size');
res.json({ font_size });
});

api.get('/flags', (req, res) => {
flagsmith.getFlags()
.then((flags) => {
res.json(flags)
});
api.get('/flags', async (req, res) => {
const flags = await flagsmith.getFlags();
res.json(flags);
});

api.get('/:user', (req, res) => {
flagsmith.getValue("font_size", "flagsmith_sample_user")
.then((font_size) => {
res.json({font_size})
});
api.get('/:user', async (req, res) => {
const font_size = await flagsmith.getValue('font_size', req.params.user);
res.json({ font_size });
});

return api;
Expand Down
9 changes: 3 additions & 6 deletions example/server/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
global.fetch = require('fetchify')(Promise).fetch; // polyfil

const http = require('http');
const express = require('express');
const api = require('./api');
Expand All @@ -16,16 +14,15 @@ app.use(bodyParser.json());
// api router
app.use('/', api());


app.server.listen(PORT);
console.log('Server started on port ' + app.server.address().port);
console.log();
console.log('Go to http://localhost:'+PORT+'/');
console.log('Go to http://localhost:' + PORT + '/');
console.log('To get an example feature state');
console.log();
console.log('Go to http://localhost:'+PORT+'/flagsmith_sample_user');
console.log('Go to http://localhost:' + PORT + '/flagsmith_sample_user');
console.log('To get an example feature state for a user');
console.log('Go to http://localhost:'+PORT+'/flags');
console.log('Go to http://localhost:' + PORT + '/flags');
console.log('To get an example response for getFlags');

module.exports = app;
Loading