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

@devakumaraswamy/create-react-viya-app

v0.3.0

Published

a cli for creating react+restaf based apps for Viya

Downloads

6

Readme

create-react-restaf-viya-app

create-react-app from Facebook is a very popular cli for jump starting developing react apps.One of its key features is the Hot Module Replacement which recompiles and updates the display as the code is being updated.

Additionally when developing Viya apps the code needs to access SAS Viya using the REST APIs.

This extension of create-react-app is designed to help developer's building react apps using restaf library and its companions:

  1. restaf
  2. restaflib
  3. restaf-server

create-react-restaf-viya

There is a fully functional demo in the demo directory of this repository. It uses material-ui as the primary UI framework.

Key Assumption

The application is authenticated using authorization_code flow.

App Creation

npx create-react-viya-app react-appname --webapp webapp-name  --title webapp-title --script scriptTags-file

Only the react-appname is required. The optional parameters are:

  • webapp -- this is the user-friendly application name. Defaults to viyademo

  • title -- The text for the title tag in index.html. Defaults to SAS/Viya Application

  • script -- a file which has some HTML script tags to be inserted into index.html - defaults is a comment line

Configuration

Set the following in the .env file:

  • CLIENTID -- the default value is viyademo
  • CLIENTSECRET -- the default value is secret
  • VIYA_SERVER -- no defaults

Some defaults:

  1. The app server runs on localhost:5000/viyademo
  2. The clientid redirect is http://localhost:5000/viyademo
  3. The create-react-app server runs on its standard port(3000)

For more detailed configuration ioptions see See https://github.com/sassoftware/restaf-server/wiki

Development mode

Run this command to have HMR enabled

cd to-the-app-directory
yarn dev

Application mode

Run this command( no HMR)

cd to-the-app-directory
yarn build
yarn app

Then use the created app just as you would any app created with create-react-app

React Context - AppContext

By default a react context named AppContext is created.

To access the data code something like this:


import React,{useContext} from 'react';
import AppContext from '../providers/AppContext';

let appContext = useContext(AppContext);

let {store, appOptions} = appContext;

let {appenv, logonPayload} = appOptions;

The store is the restaf store object that you will use to make the API calls.

Requiring restaf and restaflib in your application

These two libraries are part of the installed dependencies. To access them in your react components do these as follows:

let restaf = require('@sassoftware/restaf/dist/restaf.js');
let restaflib = require('@sassoftware/restaflib/dist/restaflib.js');

or

import * as restaf from '@sassoftware/restaf/dist/restaf.js';
import * as restaflib from import * as restaf from '@sassoftware/restaf/dist/restaflib.js';

In all probablity you will not refer directly to restaf in your code. You will use the store object in the AppContext(see above). This value is set as part of the application setup.