Skip to content

Commit

Permalink
Version 1.0.1 (#21)
Browse files Browse the repository at this point in the history
* change license from ISC to MIT

* include src in files

* update package name to 'breinify-react'

* remove Object.freeze in BreinifySetup

This resulted in one of the tests failing -  'should throw when trying to change BreinifyGlobalConfigs'

I remove this test since the removal of Object.freeze completely nullifies this test

* Bundle ts files into build (#22)

* Breinify logo

Co-authored-by: Alvin <[email protected]>
  • Loading branch information
timothyyue-b and akwong2 authored Aug 26, 2022
1 parent 1004a10 commit a5e86b2
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 36 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p align="center">
<img src="https://www.breinify.com/img/Breinify_logo.png" alt="Breinify API JavaScript Library" width="250">
</p>

# Breinify’s React API Library

<!-- TOC -->
Expand All @@ -21,15 +25,15 @@ It is recommended to use signed messages when utilizing the react library. A sig
#### utakxp7sm6weo5gvk7cytw==

### Installing
The library is available on [npm](https://www.npmjs.com/package/brein-react-api-library-react) and can be added using:
The library is available on [npm](https://www.npmjs.com/package/breinify-react) and can be added using:
```bash
npm i brein-react-api-library-react --save
npm i breinify-react
```

### Configuring the Library
Whenever the library is used, it needs to be configured, i.e., the configuration defines which API key and which secret (if signed messages are enabled, i.e., `Verification Signature` is checked) to use. Please place `BreinifySetup` on the top most section of your application. <br/>**Warning: Only call BreinSetup once in your application!**
```tsx
import { BreinifySetup } from 'brein-api-library-react';
import { BreinifySetup } from 'breinify-react';

const apiKey = '938D-3120-64DD-413F-BB55-6573-90CE-473A';
const secret = 'utakxp7sm6weo5gvk7cytw==';
Expand Down
4 changes: 2 additions & 2 deletions docs/recommendations/recommendations.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ getRecs({user, unixTimestamp, signature, recommendation, recommendations}: Recom

#### Example
```tsx
import { useRecommendations } from "brein-api-library-react";
import { useRecommendations } from "breinify-react";

export function TestContainer() {
const { getRecs, data, isInit, isLoading, isSuccess, isFailure, error } =
Expand Down Expand Up @@ -172,7 +172,7 @@ Our Carousel extends [react-slick](https://react-slick.neostack.com/docs/api).
#### Example
```tsx
import React from "react";
import { Carousel } from "brein-api-library-react";
import { Carousel } from "breinify-react";

export const CarouselTest = () => {
return (
Expand Down
60 changes: 58 additions & 2 deletions package-lock.json

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

11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "breinify-react",
"version": "1.0.0",
"version": "1.0.1",
"description": "React Library for the Breinify API",
"main": "dist/cjs/index.js",
"types": "dist/index.d.ts",
"module": "dist/esm/index.js",
"scripts": {
"build": "rollup --config",
Expand All @@ -16,13 +17,16 @@
"type": "git",
"url": "git+https://github.com/Breinify/brein-api-library-react.git"
},
"files": ["dist/*"],
"files": [
"dist/*",
"src"
],
"keywords": [],
"authors": [
"Alvin Kwong <[email protected]>",
"Timothy Yue <[email protected]>"
],
"license": "ISC",
"license": "MIT",
"bugs": {
"url": "https://github.com/Breinify/brein-api-library-react/issues"
},
Expand Down Expand Up @@ -73,6 +77,7 @@
"react-dom": "^18.0.0",
"react-test-renderer": "^18.0.0",
"rollup": "^2.75.7",
"rollup-plugin-dts": "^4.2.2",
"rollup-plugin-import-css": "^3.0.3",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.2",
Expand Down
44 changes: 28 additions & 16 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { terser } from 'rollup-plugin-terser';
import external from 'rollup-plugin-peer-deps-external';
import visualizer from 'rollup-plugin-visualizer';
import postcss from 'rollup-plugin-postcss';
import dts from 'rollup-plugin-dts';

const PLUGINS = [
external(),
Expand All @@ -19,21 +20,32 @@ const PLUGINS = [

const pkg = require('./package.json');

export default {
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true,
name: 'react-lib',
},
{
file: pkg.module,
export default [
{
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true,
name: 'react-lib',
},
{
file: pkg.module,
format: 'esm',
sourcemap: true,
},
],
plugins: [...PLUGINS, terser()],
external: ['react', 'react-dom'],
},
{
input: 'dist/esm/types/index.d.ts',
output: {
file: pkg.types,
format: 'esm',
sourcemap: true,
},
],
plugins: [...PLUGINS, terser()],
external: ['react', 'react-dom'],
};
external: [/\.(scss|css)$/],
plugins: [dts()],
},
];
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './configs';
export * from './setup';
export * from './hooks';
export * from './components';
export * from './types';
9 changes: 0 additions & 9 deletions src/setup/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,4 @@ describe('Setup functions', () => {
expect(() => Setup.BreinifySetup(ARRAY as any)).toThrow();
expect(() => Setup.BreinifySetup(NUMBER as any)).toThrow();
});

test('should throw when trying to change BreinifyGlobalConfigs', () => {
const Setup = require('./setup');
const API_KEY = 'API_KEY';
Setup.BreinifySetup({ apiKey: API_KEY });

expect(() => (Setup.BreinifyGlobalConfigs.apiKey = 'apiKey')).toThrow();
expect(() => (Setup.BreinifyGlobalConfigs.secret = 'secret')).toThrow();
});
});
1 change: 0 additions & 1 deletion src/setup/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export function BreinifySetup({ apiKey, secret }: SetupProps): void {
if (secret && !isString(secret)) throw 'Secret needs to be a string';
BreinifyGlobalConfigs.apiKey = apiKey;
BreinifyGlobalConfigs.secret = secret;
Object.freeze(BreinifyGlobalConfigs);
}

// Checks if BreinifySetup is complete
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"baseUrl": ".",
"declaration": true,
"outDir": "types",
"emitDeclarationOnly": true
}
}

0 comments on commit a5e86b2

Please sign in to comment.