diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..94a2dd1 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +*.json \ No newline at end of file diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..80a762e --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,9 @@ +module.exports = { + bracketSpacing: true, + printWidth: 100, + singleQuote: true, + tabWidth: 4, + trailingComma: 'none', + useTabs: false, + arrowParens: 'avoid' +}; diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6bebc39..48d8ad0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 @@ -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. \ No newline at end of file +- 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. diff --git a/LICENCE.md b/LICENCE.md index e57593a..be8d20d 100644 --- a/LICENCE.md +++ b/LICENCE.md @@ -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. \ No newline at end of file +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. diff --git a/example/README.md b/example/README.md index c89c13a..c221528 100644 --- a/example/README.md +++ b/example/README.md @@ -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 diff --git a/example/package-lock.json b/example/package-lock.json index 3047701..12f0331 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -59,6 +59,11 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" }, + "clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=" + }, "commander": { "version": "2.17.1", "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", @@ -288,14 +293,6 @@ } } }, - "flagsmith-nodejs": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/flagsmith-nodejs/-/flagsmith-nodejs-1.0.8.tgz", - "integrity": "sha512-8P61TYk9odceeczMT7Ex2UGTQe86fYbF7g4oWtLCcR/aIc6rn0OZQQxSRRxwlcararL4EcCJDjJdsvYddxudDw==", - "requires": { - "node-fetch": "^2.1.2" - } - }, "forwarded": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", @@ -470,10 +467,13 @@ "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==" }, - "node-fetch": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + "node-cache": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/node-cache/-/node-cache-5.1.2.tgz", + "integrity": "sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg==", + "requires": { + "clone": "2.x" + } }, "object-assign": { "version": "4.1.1", diff --git a/example/package.json b/example/package.json index b280137..95b32c6 100644 --- a/example/package.json +++ b/example/package.json @@ -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" }, diff --git a/example/server/api/index.js b/example/server/api/index.js index f3932ff..cbcd75e 100644 --- a/example/server/api/index.js +++ b/example/server/api/index.js @@ -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; diff --git a/example/server/index.js b/example/server/index.js index 778994a..7e0014e 100755 --- a/example/server/index.js +++ b/example/server/index.js @@ -1,5 +1,3 @@ -global.fetch = require('fetchify')(Promise).fetch; // polyfil - const http = require('http'); const express = require('express'); const api = require('./api'); @@ -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; diff --git a/flagsmith-core.js b/flagsmith-core.js index 3261e9c..8b31174 100644 --- a/flagsmith-core.js +++ b/flagsmith-core.js @@ -1,238 +1,241 @@ -let fetch; - -const FlagsmithCore = class { - - constructor(props) { - fetch = props.fetch; - - this.checkFeatureEnabled = this.checkFeatureEnabled.bind(this); - this.getFlags = this.getFlags.bind(this); - this.getFlagsForUser = this.getFlagsForUser.bind(this); - this.getUserIdentity = this.getUserIdentity.bind(this); - this.getValue = this.getValue.bind(this); - this.getValueFromFeatures = this.getValueFromFeatures.bind(this); - this.hasFeature = this.hasFeature.bind(this); - this.init = this.init.bind(this); - - this.getJSON = function (url, method, body) { - const { environmentID } = this; - const options = { - method: method || 'GET', - body, - headers: { - 'x-environment-key': environmentID - } +const fetch = require('node-fetch'); + +module.exports = class FlagsmithCore { + normalizeFlags(flags) { + const _flags = {}; + + for (const { feature, enabled, feature_state_value } of flags) { + const normalizedKey = feature.name.toLowerCase().replace(/ /g, '_'); + _flags[normalizedKey] = { + enabled, + value: feature_state_value }; - if (method !== "GET") { - options.headers['Content-Type'] = 'application/json; charset=utf-8'; - } - return fetch(url, options) - .then(res => { - return res.json() - .then(result => { - if (res.status < 200 || res.status >= 400) { - Promise.reject(new Error(result.detail)) - } else return result; - }) - }); - }; + } + + return _flags; } - getFlagsForUser (identity) { - const { onError, api } = this; + normalizeTraits(traits) { + const _traits = {}; - if (!identity) { - onError && onError({message: 'getFlagsForUser() called without a user identity'}); - return Promise.reject('getFlagsForUser() called without a user identity'); - } - - const handleResponse = (res) => { - // Handle server response - let flags = {}; - res.flags.forEach(feature => { - flags[feature.feature.name.toLowerCase().replace(/ /g, '_')] = { - enabled: feature.enabled, - value: feature.feature_state_value - }; - }); - return flags; - }; + for (const { trait_key, trait_value } of traits) { + const normalizedKey = trait_key.toLowerCase().replace(/ /g, '_'); + _traits[normalizedKey] = trait_value; + } - return this.getJSON(api + 'identities/?identifier=' + identity) - .then(res => { - return handleResponse(res); - }).catch(({ message }) => { - onError && onError({ message }); - return Promise.reject(message); - }); + return _traits; } - getUserIdentity (identity) { - const { onError, api } = this; - - if (!identity) { - onError && onError({message: 'getUserIdentity() called without a user identity'}); - return Promise.reject('getUserIdentity() called without a user identity'); - } - - const handleResponse = (res) => { - // Handle server response - let flags = {}; - let traits = {}; - res.flags.forEach(feature => { - flags[feature.feature.name.toLowerCase().replace(/ /g, '_')] = { - enabled: feature.enabled, - value: feature.feature_state_value - }; - }); - res.traits.forEach(({trait_key, trait_value}) => { - traits[trait_key.toLowerCase().replace(/ /g, '_')] = trait_value; - }); - return { flags, traits }; + async getJSON(url, method, body) { + const { environmentID } = this; + const options = { + method: method || 'GET', + body, + headers: { + 'x-environment-key': environmentID + } }; - return this.getJSON(api + 'identities/?identifier=' + identity) - .then(res => { - return handleResponse(res); - }).catch(({ message }) => { - onError && onError({ message }); - return Promise.reject(message); - }); - } + if (method !== 'GET') { + options.headers['Content-Type'] = 'application/json; charset=utf-8'; + } - getFlags() { - const { onError, api } = this; + const res = await fetch(url, options); + const result = await res.json(); - const handleResponse = (res) => { - // Handle server response - let flags = {}; - res.forEach(feature => { - flags[feature.feature.name.toLowerCase().replace(/ /g, '_')] = { - enabled: feature.enabled, - value: feature.feature_state_value - }; - }); - return flags; - }; + if (res.status >= 400) { + throw new Error(result.detail); + } - return this.getJSON(api + "flags/") - .then(res => { - return handleResponse(res); - }).catch(({ message }) => { - onError && onError({ message }); - return Promise.reject(message); - }); - }; - - init({ - environmentID, - api, - disableCache, - onError, - }) { + return result; + } + + init({ environmentID, api, onError, cache }) { if (!environmentID) { throw new Error('Please specify a environment id'); } this.environmentID = environmentID; - this.api = api || "https://api.bullet-train.io/api/v1/"; - this.disableCache = disableCache; + this.api = api || 'https://api.flagsmith.com/api/v1'; this.onError = onError; - } - getValue (key, userId) { - if (userId) { - return this.getFlagsForUser(userId).then((flags) => { - return this.getValueFromFeatures(key, flags); - }) - } else { - return this.getFlags().then((flags) => { - return this.getValueFromFeatures(key, flags); + if (cache) { + const missingMethods = []; + + ['has', 'get', 'set'].forEach(method => { + if (!cache[method]) missingMethods.push(method); }); + + if (missingMethods.length > 0) { + throw new Error( + `Please implement the following methods in your cache: ${missingMethods.join( + ', ' + )}` + ); + } } + + this.cache = cache; } - hasFeature (key, userId) { - if (userId) { - return this.getFlagsForUser(userId).then((flags) => { - return this.checkFeatureEnabled(key, flags); - }) - } else { - return this.getFlags().then((flags) => { - return this.checkFeatureEnabled(key, flags); - }); + async getFlags() { + if (this.cache && (await this.cache.has('flags'))) { + return this.cache.get('flags'); + } + + const { onError, api } = this; + + try { + const flags = await this.getJSON(`${api}/flags/`); + const normalizedFlags = this.normalizeFlags(flags); + + if (this.cache) await this.cache.set('flags', normalizedFlags); + + return normalizedFlags; + } catch (err) { + onError && onError({ message: err.message }); + throw err; } } - getValueFromFeatures (key, flags) { - if (!flags) { - return null; + async getFlagsForUser(identity) { + const cacheKey = `flags-${identity}`; + + if (this.cache && (await this.cache.has(cacheKey))) { + return this.cache.get(cacheKey); } - const flag = flags[key]; - let res = null; - if (flag) { - res = flag.value; + + const { onError, api } = this; + + if (!identity) { + const errMsg = 'getFlagsForUser() called without a user identity'; + onError && onError({ message: errMsg }); + throw new Error(errMsg); } - //todo record check for value - return res; + try { + const { flags } = await this.getJSON(`${api}/identities/?identifier=${identity}`); + const normalizedFlags = this.normalizeFlags(flags); + + if (this.cache) await this.cache.set(cacheKey, normalizedFlags); + + return normalizedFlags; + } catch (err) { + onError && onError({ message: err.message }); + throw err; + } } - checkFeatureEnabled (key, flags) { - if (!flags) { - return false; + async getUserIdentity(identity) { + const cacheKey = `flags_traits-${identity}`; + + if (this.cache && (await this.cache.has(cacheKey))) { + return this.cache.get(cacheKey); } - const flag = flags[key]; - let res = false; - if (flag && flag.enabled) { - res = true; + + const { onError, api } = this; + + if (!identity) { + const errMsg = 'getUserIdentity() called without a user identity'; + onError && onError({ message: errMsg }); + throw new Error(errMsg); } - return res; + try { + const { flags, traits } = await this.getJSON( + `${api}/identities/?identifier=${identity}` + ); + + const normalizedFlags = this.normalizeFlags(flags); + const normalizedTraits = this.normalizeTraits(traits); + const res = { flags: normalizedFlags, traits: normalizedTraits }; + + if (this.cache) await this.cache.set(cacheKey, res); + + return res; + } catch (err) { + onError && onError({ message: err.message }); + throw err; + } } - getTrait (identity, key) { + async getValue(key, userId) { + const flags = userId ? await this.getFlagsForUser(userId) : await this.getFlags(); + + return this.getValueFromFeatures(key, flags); + } + + async hasFeature(key, userId) { + const flags = userId ? await this.getFlagsForUser(userId) : await this.getFlags(); + + return this.checkFeatureEnabled(key, flags); + } + + getValueFromFeatures(key, flags) { + if (!flags) return null; + + const flag = flags[key]; + + //todo record check for value + return flag ? flag.value : null; + } + + checkFeatureEnabled(key, flags) { + if (!flags) return false; + + const flag = flags[key]; + return flag && flag.enabled; + } + + async getTrait(identity, key) { const { onError } = this; if (!identity || !key) { - onError && onError({message: `getTrait() called without a ${!identity ? 'user identity' : 'trait key'}`}); - return Promise.reject(`getTrait() called without a ${!identity ? 'user identity' : 'trait key'}`); + const errMsg = `getTrait() called without a ${ + !identity ? 'user identity' : 'trait key' + }`; + onError && onError({ message: errMsg }); + throw new Error(errMsg); } - return this.getUserIdentity(identity) - .then(({traits}) => traits[key]) - .catch(({ message }) => { - onError && onError({ message }); - return Promise.reject(message); - }); + try { + const { traits } = await this.getUserIdentity(identity); + return traits[key]; + } catch (err) { + onError && onError({ message: err.message }); + throw err; + } } - setTrait (identity, key, value) { + async setTrait(identity, key, value) { const { onError, api } = this; if (!identity || !key) { - onError && onError({message: `setTrait() called without a ${!identity ? 'user identity' : 'trait key'}`}); - return Promise.reject(`setTrait() called without a ${!identity ? 'user identity' : 'trait key'}`); + const errMsg = `setTrait() called without a ${ + !identity ? 'user identity' : 'trait key' + }`; + onError && + onError({ + message: errMsg + }); + throw new Error(errMsg); } const body = { - "identity": { - "identifier": identity + identity: { + identifier: identity }, - "trait_key": key, - "trait_value": value - } + trait_key: key, + trait_value: value + }; - return this.getJSON(`${api}traits/`, 'POST', JSON.stringify(body)) - .then(() => this.getUserIdentity(identity)) - .catch(({ message }) => { - onError && onError({ message }); - return Promise.reject(message); - }); + try { + await this.getJSON(`${api}/traits/`, 'POST', JSON.stringify(body)); + return await this.getUserIdentity(identity); + } catch (err) { + onError && onError({ message: err.message }); + throw err; + } } }; - -module.exports = function ({ fetch }) { - return new FlagsmithCore({ fetch }); -}; diff --git a/index.d.ts b/index.d.ts index 49c3ec9..eeac23b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,51 +3,52 @@ declare module 'flagsmith-nodejs' { * Initialise the sdk against a particular environment */ export function init(config: { - environmentID: string - onError?: Function - defaultFlags?: string[] - api?: string - }): void + environmentID: string; + onError?: Function; + defaultFlags?: string[]; + api?: string; + cache?: ICache; + }): void; /** * Get the whether a flag is enabled e.g. flagsmith.hasFeature("powerUserFeature") */ - export function hasFeature(key: string): Promise + export function hasFeature(key: string): Promise; /** * Get the value of a whether a flag is enabled for a user e.g. flagsmith.hasFeature("powerUserFeature", 1234) */ - export function hasFeature(key: string, userId: string): Promise + export function hasFeature(key: string, userId: string): Promise; /** * Get the value of a particular remote config e.g. flagsmith.getValue("font_size") */ - export function getValue(key: string): Promise + export function getValue(key: string): Promise; /** * Get the value of a particular remote config for a specified user e.g. flagsmith.getValue("font_size", 1234) */ - export function getValue(key: string, userId: string): Promise + export function getValue(key: string, userId: string): Promise; /** * Trigger a manual fetch of the environment features */ - export function getFlags(): Promise + export function getFlags(): Promise; /** * Trigger a manual fetch of the environment features for a given user id */ - export function getFlagsForUser(userId: string): Promise + export function getFlagsForUser(userId: string): Promise; /** * Trigger a manual fetch of both the environment features and users' traits for a given user id */ - export function getUserIdentity(userId: string): Promise + export function getUserIdentity(userId: string): Promise; /** * Trigger a manual fetch of a specific trait for a given user id */ - export function getTrait(userId: string, key: string): Promise + export function getTrait(userId: string, key: string): Promise; /** * Set a specific trait for a given user id @@ -55,24 +56,30 @@ declare module 'flagsmith-nodejs' { export function setTrait( userId: string, key: string, - value: string|number|boolean - ): IUserIdentity + value: string | number | boolean + ): IUserIdentity; interface IFeature { - enabled: boolean - value?: string|number|boolean + enabled: boolean; + value?: string | number | boolean; } interface IFlags { - [key: string]: IFeature + [key: string]: IFeature; } interface ITraits { - [key: string]: string + [key: string]: string; } interface IUserIdentity { - flags: IFeature - traits: ITraits + flags: IFeature; + traits: ITraits; + } + + interface ICache { + has(key: string): boolean | Promise; + get(key: string): any | Promise; + set(key: string, val: any): void | Promise; } } diff --git a/index.js b/index.js index 13d7748..54eefae 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,3 @@ -const fetch = require('node-fetch').default; -const core = require('./flagsmith-core'); -const flagsmith = core({fetch: fetch}); +const FlagsmithCore = require('./flagsmith-core'); -module.exports = flagsmith; +module.exports = new FlagsmithCore(); diff --git a/package-lock.json b/package-lock.json index f82f748..97819ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "flagsmith-nodejs", - "version": "1.0.8", + "version": "1.0.9", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -8,6 +8,12 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz", "integrity": "sha1-q4hOjn5X44qUR1POxwb3iNF2i7U=" + }, + "prettier": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz", + "integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==", + "dev": true } } } diff --git a/package.json b/package.json index 23ee71d..f2e65fe 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,13 @@ } ], "license": "MIT", + "scripts": { + "lint": "prettier --write ." + }, "dependencies": { "node-fetch": "^2.1.2" + }, + "devDependencies": { + "prettier": "^2.2.1" } }