Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bluecadet/launchpad-content

Package Overview
Dependencies
Maintainers
0
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bluecadet/launchpad-content

Content syncing pipeline for various sources

  • 2.0.0-next.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
decreased by-90.64%
Maintainers
0
Weekly downloads
 
Created
Source

Launchpad Content

The content package downloads and locally caches content from various common web APIs.

To download content, all you need to do is define content sources and provide credentials as needed.

The following launchpad.json would download jsons and images from the Flickr API to .downloads/flickr-images (a combination of the default .downloads/ directory and the id field of the content source):

{
  "content": {
    "sources": [
      {
        "id": "flickr-images",
        "type": "json",
        "files": {
            "spaceships.json": "https://api.flickr.com/services/feeds/photos_public.gne?format=json&nojsoncallback=1&tags=spaceship",
            "rockets.json": "https://api.flickr.com/services/feeds/photos_public.gne?format=json&nojsoncallback=1&tags=rocket"
        }
      }
    ]
  }
}

See ContentOptions Parameters for a full list of content settings.

Source Settings

Every source needs:

  • id: ID of the individual source (required)
  • type: Source type (default: json)
  • Additional source-specific settings

Currently supported sources are:

Authentication

Some content sources require credentials to access their APIs.

These can all be stored in a .env or .env.local file which will be automatically loaded by launchpad.

.env.local

AIRTABLE_API_KEY=<YOUR_AIRTABLE_API_KEY>

CONTENTFUL_PREVIEW_TOKEN=<YOUR_CONTENTFUL_PREVIEW_TOKEN>
CONTENTFUL_DELIVERY_TOKEN=<YOUR_CONTENTFUL_DELIVERY_TOKEN>
CONTENTFUL_USE_PREVIEW_API=false

SANITY_API_TOKEN=<YOUR_API_TOKEN>

STRAPI_IDENTIFIER=<YOUR_API_USER>
STRAPI_PASSWORD=<YOUR_API_PASS>

launchpad.config.js

export default defineConfig({
	content: {
		sources: [
			{
				id: "airtable-cms",
				type: "airtable",
				apiKey: process.env.AIRTABLE_API_KEY,
			},
			{
				id: "contentful-cms",
				type: "contentful",
				previewToken: process.env.CONTENTFUL_PREVIEW_TOKEN,
				deliveryToken: process.env.CONTENTFUL_DELIVERY_TOKEN,
				usePreviewApi: false,
			},
			{
				id: "sanity-cms",
				type: "sanity",
				apiToken: process.env.SANITY_API_TOKEN,
			},
			{
				id: "strapi-cms",
				type: "strapi",
				identifier: process.env.STRAPI_IDENTIFIER,
			},
		],
	},
});

Post Processing

Once content is downloaded it can be processed to transform text and images. For example, launchpad can convert markdown to html and create scaled derivatives of each image.

ContentOptions

Options for all content and media downloads. Each of these settings can also be configured per ContentSource.

PropertyTypeDefaultDescription
sourcesArray.<SourceOptions>[]A list of content source options. This defines which content is downloaded from where.
imageTransformsArray.<Object.<string, number>>[]A list of image transforms to apply to a copy of each downloaded image.
contentTransformsObject.<string, string>{}A list of content transforms to apply to all donwloaded content.
downloadPathstring'.downloads/'The path at which to store all downloaded files.
credentialsPathstring'.credentials.json'The path to the json containing credentials for all content sources.
tempPathboolean'%DOWNLOAD_PATH%/.tmp/'Temp file directory path.
backupPathboolean'%DOWNLOAD_PATH%/.backups/'Temp directory path where all downloaded content will be backed up before removal.
keepboolean''Which files to keep in dest if clearOldFilesOnSuccess or clearOldFilesOnStart are true. E.g. '\*.json|\*.csv|\*.xml|\*.git\*'
stripstring''Strips this string from all media file paths when saving them locally
backupAndRestorebooleantrueBack up files before downloading and restore originals for all sources on failure of any single source.
maxConcurrentnumber4Max concurrent downloads.
maxTimeoutnumber30000Max request timeout in ms.
clearOldFilesOnSuccessbooleantrueRemove all existing files in dest dir when downloads succeed. Ignores files that match keep
clearOldFilesOnStartbooleanfalseWill remove all existing files _before_ downloads starts. false will ensure that existing files are only deleted after a download succeeds.
ignoreCachebooleanfalseWill always download files regardless of whether they've been cached
enableIfModifiedSinceCheckbooleantrueEnables the HTTP if-modified-since check. Disabling this will assume that the local file is the same as the remote file if it already exists.
enableContentLengthCheckbooleantrueCompares the HTTP header content-length with the local file size. Disabling this will assume that the local file is the same as the remote file if it already exists.
abortOnErrorbooleantrueIf set to true, errors will cause syncing to abort all remaining tasks immediately
ignoreImageTransformCachebooleanfalseSet to true to always re-generate transformed images, even if cached versions of the original and transformed image already exist.
ignoreImageTransformErrorsbooleantrueSet to false if you want to abort a content source from downloading if any of the image transforms fail. Leaving this to true will allow for non-image files to fail quietly.
forceClearTempFilesbooleantrueSet to false if you want to keep all contents of the tempPath dir before downloading

FAQs

Package last updated on 30 Oct 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc