npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

twreporter-react-redux-registration

v1.0.0-alpha-0.1

Published

registration sginIn system

Downloads

3

Readme

TW Reporter Registration Package

Host Project Environment

  • The host project need to contain following:

    1. react
    2. redux
    3. react-router
    4. express server
  • Bonus: The package work with next.js

Installation

npm i --save twreporter-registration

Work Flow

List of Containers/Components and Reducers

Containers

  • ActivePage
  • AuthenticationScreen
  • Features
  • SignInForm
  • SignUpForm

Components

  • SignOut

Reducers

  • authReducer
  • configure user has to pass api url initial state obj to configure reducer
import { configureReducer } from 'twreporter-registration'
const registrationInitialState = {
  apiUrl: '',
  signUp: '',
  signIn: '',
  activate: '',
  bookmarkUpdate: '',
  bookmarkDelete: '',
  bookmarkGet: '',
  ping: '',
  oAuthProviders: {
    google: '',
    facebook: '',
  },
},
const configReducer = configureReducer(registrationInitialState)
const rootReducer = combineReducers({
  authConfigure: configReducer,
})

Usage js

  • import containers/components from twreporter-registration to react router js file of your host project. Most of containers is pretty handy, However, some complex containers need specific properties or can only be used in specific circumstances.
    • AuthenticationScreen: is only for client side
    • SignInForm has following properties (you can pass properties through react-router or jsx it self.)
      • title (string): form title
      • browserHistory (func): browserHistory from router or Router of next.js
      • AssignedLink (func): This one is only for next.js Link
      • signInRedirectPath (signin):
      • location: query data for TWReporter GO_API (after oAuth)
      • domain: query data for TWReporter GO_API (after oAuth)
      • account (boolean): show SignIn SignUp function
      • google (boolean): show google function
      • facebook (boolean): show facebook function
      • defaultStyle (boolean): with defaultStyle or not (for now the difference is only on frame size and location)
    • ActivateForm
      • query: pass your query data from next.js or just put null for react-router
      • browserHistory: browserHistory of react-router or Router of next.js
      • activateRedirectPath: '/yourpage'
import { SignUpForm, SignInForm, ActivePage, AuthenticationScreen, Features, SignOut } from 'twreporter-registration'
export default function (history = browserHistory) {
return (
 <Router history={history} >
   <Route path="/" component={App}>
     <IndexRoute component={Home} />
     <Route
        path="signup"
        component={SignUpForm}
     />
     <Route
        path="signin"
        component={SignInForm}
        title={'Sign In to TWReporter'}
        browserHistory={browserHistory}
        signInRedirectPath = {'/features'}
        location={'http://testtest.twreporter.org:3000/features'}
        domain={'twreporter.org'}
        account={false}
        facebook={true}
        google={true}
        defaultStyle={false}
     />
     <Route
        path="activate"
        component={ActivePage}
        query={this.props.query/null}
        browserHistory={Router}
        activateRedirectPath={'/content'}
     />
     <Route
        path="features"
        component={AuthenticationScreen(Features)}
        redirectPath={'/signin'}
     />
     <Route
        path="signout"
        component={SignOut}
     />
   </Route>
 </Router>
)
}
  • import reducers from twreporter-registration to root reducer
import { authReducer, oauthReducer, configureReducer } from 'twreporter-registration'
const rootReducer = combineReducers({
   authConfigure: configureReducer,
   oauth: oauthReducer,
   auth: authReducer,
})
  • import actions from from package
    We provide you a default structure of path of authentication api server. You only need to enter your paths into registrationConfigure obj which is presented at following example.
// in your render file
import { types, configureAction } from 'twreporter-registration'
const registrationConfigure = {
    apiUrl: 'http://testtest.twreporter.org/8080',
    signUp: '/v1/signup',
    signIn: '/v1/login',
    activate: '/v1/activate',
    bookmarkUpdate: '',
    bookmarkDelete: '',
    bookmarkGet: '',
    ping: '',
    oAuthProviders: {
      google: '/v1/auth/google',
      facebook: '/v1/auth/facebook'
    }
}
// before render, you have to dispatch configureAction from our package
// you can to choose either server side or client side rendering
store.dispatch(configureAction(registrationConfigure))
ReactDOM.render((
  <Provider store={store}>
    <DeviceProvider device={device}>
      { createRoutes(history) }
    </DeviceProvider>
  </Provider>
), document.getElementById('root'))
  • Processing auth_info from Respond/Cookies (in your express server)
import { authInfoStringToObj } from 'twreporter-registration'
let authInfoObj = authInfoStringToObj(auth_info_string)
store.dispatch(authUserAction(authType, authInfoObj))

Next.js Example

class SignIn extends React.Component {
  static getInitialProps ({ store }) {
    const registrationConfigure = {
      apiUrl: 'http://testtest.twreporter.org:8080',
      signUp: '/v1/signup',
      signIn: '/v1/login',
      activate: '/v1/activate',
      bookmarkUpdate: '',
      bookmarkDelete: '',
      bookmarkGet: '',
      ping: '',
      oAuthProviders: {
        google: '/v1/auth/google',
        facebook: '/v1/auth/facebook'
      }
    }
    store.dispatch(configureAction(registrationConfigure))
  }

  render() {
    return (
      <SignInForm
        title={'Sign In to Newsletter'}
        browserHistory={Router}
        AssignedLink={Link}
        signInRedirectPath={'/features'}
        location={'http://testtest.twreporter.org:3000/features'}
        domain={'twreporter.org'}
        account={false}
        facebook={true}
        google={true}
        defaultStyle={false}
      />
    )
  }
}

Development

npm run dev   //development mode
npm run build //production mode
  • advice for developer/programmer: You can program in es2015 + es2017 and only need to edit files in src directory. All files will be transpiled through babel-preset-es2017 and transfered to lib directory.

  • Working On

  1. modify AuthScreen Component to be compatible with next.js
  2. Make Token Manager to be available
  3. Reassemble localStorage data