Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@sassoftware/create-react-restaf-viya-app
Advanced tools
a cli for creating react+restaf based apps for Viya
create-react-app is a very popular cli to jump start the development of react-based applications.
create-react-restaf-viya-app is an extension of create-react-app. The target audience is react developers building SAS Viya Apps.
Some of the benefits of using this cli to jump start your SAS Viya Applications
You retain all the benefits of using create-react-app which are well documented
You are automatically authenticated to the Viya Server.
You can start making API calls right away during development just as you would in production.
The recommended way is to use restaf and restaflib to make the REST API calls. See the sample application created on your first creation of the application.
If for some reason[the author can think of none] you would prefer to hand-code the calls you can do that too. Remember that the session is authenticated using authorization_code flow and code appropriately.
Issue the command below to create the default application.
npx create-react-restaf-viya-app react-appname --webapp webapp-name --title webapp-title --script scriptTags-file --use viya-app
Example:
npx create-react-restaf-viya-app mycoolapp
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
--i -- install additional dependencies ( a quoted string like "next i18next")
--use viya-app -- Build the viya app with builtin routing (see )
Once the app has been created you can start your development.
The application is authenticated using authorization_code flow.
Set the following in the .env file:
Set VIYA_SERVER using your OS's set command. This can also be set in the env file. If you set this in env file then change the dkrrun script accordingly.
set VIYA_SERVER=<your viya server>.
For more detailed configuration options see See https://github.com/sassoftware/restaf-server/wiki
Run this command to have HMR enabled
cd to-the-app-directory
yarn dev
The flow of the application on the yarn dev command is show below.
Step 1 : User invokes the application at http://localhost:5000/viyademo
Step 2: restaf-server authenticates with the Viya Server. The user is prompted for credentials
Step 3a: Status of the initialization is displayed in the browser.
Step 3b: restaf-server runs the create-react-app's npm start script which launches your react application in a second tab of your browser.
At this point you can view your application, edit your code and see the updated application. The session is authenticated -so you can make REST API calls to SAS Viya using restaf or any other library.
Run this command. Note that the create-react-app dev server will not started.
cd to-the-app-directory
yarn build
yarn app
Use the dkrbuild and dkrrun scripts in package.json to build image and then to run it.
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';
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.
The logonPayload will have the following form:
{
authType: 'server'
host : "your Viya hostname"
}
The host value is useful if you are making use of VA_SDK and/or if you are coding the REST API calls without restaf.
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 '@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 startup.
FAQs
a cli for creating react+restaf based apps for Viya
The npm package @sassoftware/create-react-restaf-viya-app receives a total of 0 weekly downloads. As such, @sassoftware/create-react-restaf-viya-app popularity was classified as not popular.
We found that @sassoftware/create-react-restaf-viya-app demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.