Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@chec/commercerays-plugin
Advanced tools
Integrate directly with an editor within the Chec Dashboard - allowing customisation of your project by the merchant
An SDK for interfacing with the Commerce Ray dashboard to create rays that can be live edited and deployed with custom configuration
commercejs.com | @commercejs | Slack
This plugin is currently a work in progress. This code has been made open source as we intend to allow custom themes to be contributed to Commerce Rays, although this is not currently possible. As CommerceRays evolves, this plugin is likely to change significantly
Use your favourite package manager:
yarn add @chec/commercerays-plugin
# OR
npm install --save @chec/commercerays-plugin
CommerceRays are websites that have custom theme configuration provided by an API. This theme configuration is defined by a schema, and can be edited from within the Chec Dashboard (the "editor"). Projects that use this plugin are referred to as "themes", and deployed websites that combine a user-edited configuration and your theme are referred to as "rays". Many different types of configuration are supported by the editor, and are detailed in the Writing your schema section below.
Currently, NextJS is the only natively supported JS framework.
The NextJS integration provided by this plugin is intended for use with NextJS pages. The plugin will hook into
getStaticProps
and ensures that relevant data is fetched on the server side. You may either use createGetStaticProps
to generate a getStaticProps
function, or use the provided augmentStaticProps
function
pages/index.js
:
import { createGetStaticProps } from '@chec/commercerays-plugin/nextjs';
import schema from './schema.json';
const getStaticProps = createGetStaticProps(schema);
export getStaticProps;
or
import { augmentStaticProps } from '@chec/commercerays-plugin/nextjs';
import schema from './schema.json';
export function getStaticProps() {
// Custom code...
return augmentStaticProps(schema)({
// Usual return value of getStaticProps goes here
})
}
Next, you need to apply the CommerceRays React context to your page component. This is provided as a HOC as it relies on
props provided by getStaticProps
:
pages/index.js
:
import { withCommerceRays } from '@chec/commercerays-plugin/nextjs';
// Imported theme schema and theme defaults
import schema from './schema.json';
import defaultConfig from './defaults.json';
function IndexPage() {
return (
<>
<Head>
<title>My page</title>
</Head>
Hello world
</>
);
}
// You may also provide any default values for your schema here
export default withCommerceRays(schema, defaultConfig)(IndexPage);
As the user chooses values for your theme configuration (or the defaults should be used as a fallback) you will need to
access them to alter the look of the page. A React hook is provided for this, which can be used in any React component
that is a child of the page that you applied the withCommerceRays
HOC to:
import { useCommerceRay } from '@chec/commercerays-plugin/nextjs'
export function MyComponent() {
const { myConfigurationProperty } = useCommerceRay();
// ...
}
// TODO
FAQs
Integrate directly with an editor within the Chec Dashboard - allowing customisation of your project by the merchant
The npm package @chec/commercerays-plugin receives a total of 0 weekly downloads. As such, @chec/commercerays-plugin popularity was classified as not popular.
We found that @chec/commercerays-plugin 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.