-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(project): Add initial project files 🎉
- Loading branch information
0 parents
commit 5cffc2e
Showing
15 changed files
with
21,833 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"presets": [ | ||
["env", { | ||
"modules": false | ||
}], | ||
"stage-0", | ||
"react" | ||
], | ||
"plugins": [ | ||
"external-helpers" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
version: 2 | ||
jobs: | ||
test: | ||
docker: | ||
- image: circleci/node:8 | ||
steps: | ||
- checkout | ||
|
||
# Download and restore cache dependencies | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "package.json" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
|
||
- run: yarn install | ||
|
||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: v1-dependencies-{{ checksum "package.json" }} | ||
|
||
# run tests! | ||
- run: yarn test | ||
|
||
release: | ||
docker: | ||
- image: circleci/node:8 | ||
steps: | ||
- checkout | ||
- run: yarn install | ||
# Build project | ||
- run: yarn build | ||
# Release new version | ||
- run: npx semantic-release | ||
|
||
workflows: | ||
version: 2 | ||
test_and_release: | ||
# Run the test job first, then release only when the test job is successful | ||
jobs: | ||
- test | ||
- release: | ||
requires: | ||
- test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
[*.{js,css,scss,html}] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "react-app" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
node_modules | ||
|
||
# builds | ||
build | ||
dist | ||
|
||
# code coverage reports | ||
coverage | ||
|
||
# misc | ||
.DS_Store | ||
.env | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<h1 align="center">React-Router-Auth</h1> | ||
|
||
> A utility library for React Router v4 for managing authentication based routing | ||
[![NPM Version][npm-badge]][npm] | ||
[![Build Status][build-badge]][build] | ||
[![Code Coverage][coverage-badge]][coverage] | ||
|
||
This library is based off of the code from the [React Router v4 Docs](https://reacttraining.com/react-router/web/example/auth-workflow). The purpose of this library is to make it easy to handle redirecting users for routes that require the user to either be authenticated or unauthenticated. | ||
|
||
## Install | ||
|
||
```bash | ||
npm install --save react-router-auth | ||
|
||
OR | ||
|
||
yarn add react-router-auth | ||
``` | ||
|
||
## Usage | ||
|
||
### AuthRoute | ||
|
||
Use this component if you have a route that requires the user to be authenticated for them to be able to access it. | ||
|
||
e.g. to access user profile page | ||
|
||
```jsx | ||
import React, { Component } from 'react' | ||
import { AuthRoute } from 'react-router-auth' | ||
import UserProfile from './UserProfile' | ||
|
||
class Example extends Component { | ||
render () { | ||
return ( | ||
<AuthRoute path="/profile" component={UserProfile} redirectTo="/login" authenticated={this.props.authenticated} /> | ||
) | ||
} | ||
} | ||
``` | ||
|
||
In this example, if the user is authenticated while they try to access the `/profile` route, then the `UserProfile` component will be rendered. If the user is not authenticated then it will redirect them to the `/login` route. | ||
|
||
#### Props | ||
|
||
| Name | Type | Description | | ||
|---------------|-----------------|--------------------------------------------------------| | ||
| authenticated | boolean | Whether the user is authenticated or not | | ||
| redirectTo | string | The route to redirect the user to if not authenticated | | ||
| component | React Component | The component that requires authentication | | ||
|
||
### UnauthRoute | ||
|
||
Use this component if you have a route that a user should only be able to access if they aren't already authenticated. | ||
|
||
e.g. to access the login / signup pages | ||
|
||
```jsx | ||
import React, { Component } from 'react' | ||
import { UnauthRoute } from 'react-router-auth' | ||
import Login from './Login' | ||
|
||
class Example extends Component { | ||
render () { | ||
return ( | ||
<UnauthRoute path="/login" component={Login} redirectTo="/feed" authenticated={this.props.authenticated} /> | ||
) | ||
} | ||
} | ||
``` | ||
|
||
In this example, if the user is authenticated while they try to access the `login` route, they will be redirected to the `/feed` route. If the user is not authenticated, then the `Login` component will be rendered. | ||
|
||
#### Props | ||
|
||
| Name | Type | Description | | ||
|---------------|-----------------|----------------------------------------------------| | ||
| authenticated | boolean | Whether the user is authenticated or not | | ||
| redirectTo | string | The route to redirect the user to if authenticated | | ||
| component | React Component | The component that requires authentication | | ||
|
||
|
||
## License | ||
|
||
MIT © [joelseq](https://twitter.com/joelseq03) | ||
|
||
[build-badge]: https://img.shields.io/circleci/project/github/joelseq/react-router-auth.svg?style=flat-square | ||
[build]: https://circleci.com/gh/joelseq/react-router-auth | ||
[npm-badge]: https://img.shields.io/npm/v/react-router-auth.svg?style=flat-square | ||
[npm]: https://www.npmjs.com/package/react-router-auth | ||
[coverage-badge]: https://img.shields.io/codecov/c/github/joelseq/react-router-auth.svg?style=flat-square | ||
[coverage]: https://codecov.io/github/joelseq/react-router-auth |
Oops, something went wrong.