4.1.4 • Published 18 days ago

@craftercms/classes v4.1.4

Weekly downloads
157
License
GNU LGPL 3.0
Repository
github
Last release
18 days ago

npm (scoped)

@craftercms/classes

This package contains useful classes for developing craftercms websites & applications.

Usage

All of Crafter CMS packages can be used either via npm or in plain html/javascript via regular script imports.

  • Install module using yarn or npm
    • yarn add @craftercms/classes or
    • npm install @craftercms/classes
  • Import and use the classes you need

Package Index

The examples below assume usage in the style of using via npm. If you're using the bundles, directly importing as a script in the browser, these functions will be under the global variable named craftercms.classes (i.e. window.craftercms.classes).

crafterConf

Example

The crafterConf is a special class to globally configure CrafterCMS libraries. Most services you can supply these configurations on a call-by-call basis, but you may simplify by configuring all services via crafterConf early-on on your application bootstrap.

import { crafterConf } from '@craftercms/classes';

crafterConf.configure({
  // Set the base url for all service calls (i.e. urls get built `${baseUrl}/some-endpoint.json`)
  baseUrl: process.env.CRAFTER_HOST_NAME,
  // Set the site id of the site to fetch from/against
  site: process.env.CRAFTER_SITE_NAME,
  // Optionally, set cors mode to true/false (default is false)
  cors: true,
  // Optionally, set any headers you want SDK requests to go out with
  headers: {
    SOME_HEADER: 'some-value'
  }
});

SDK Service

SDKService Provides http get and post methods for Crafter services

Examples

  import { httpGet } from '@craftercms/classes';

  const requestURL = "/some-url";

  httpGet(requestURL, { 
    crafterSite: "editorial"
  }).subscribe((response) => {
    console.log(response);
  })
4.1.4

18 days ago

4.1.3

2 months ago

4.1.2-support.2

6 months ago

4.1.2

7 months ago

4.1.1

10 months ago

4.1.0

11 months ago

4.0.3

1 year ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

6 years ago