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

zen-feed

v1.0.1

Published

Express.js middleware for creating Yandex Zen RSS feed.

Downloads

3

Readme

Known Vulnerabilities Build Status Coverage Status

Zen-feed

Express.js middleware for creating Yandex Zen RSS feed.

Features

Installation

This is an Express.js middleware.

Via NPM:

npm install zen-feed

Configuration

In your express application:

const zenFeed = require('zen-feed');

zenFeed.configure(config); // call this before using middleware

app.use('/path/to/feed.rss', (req, res, next) => zenFeed.feed(req, res, next));

config should be supplied before calling zenFeed.feed

Config format:

const config = {
    rssVersion: "2.0", 
    channelTitle: "My marvelous site", 
    siteLink: "http://mysite.site", 
    channelDescription: "This is awesome site!",
    channelLanguage: "ru",
    getFeedContent: function(){...}, // see getFeedContent() section
    useParser: false 
}

Config options

| Option | Type | Description | Required? | |--------|------|-------------|-----------| | rssVersion| String | RSS version (use "2.0")|Yes| |channelTitle| String | Site name | Yes | |sitelink| String | Site URL | Yes| |channelDescription| String | Short site description | No | |channelLanguage| String | Feed language in ISO 639-1 format | No | |getFeedContent| Function | See getFeedContent() section | Yes | |useParser | Boolean | Option to use built-in parser to sanitize HTML-content. (See Sanitize section) | Yes |

getFeedContent()

In order for this middleware to actually work, you should provide async function getFeedContent. This function should return an array of publications to be included in feed. Every publication should be represented as Object. It should look like this:

const sampleItems = [
    {
        title: "Test publication",
        link: "http://testsite.site/test",
        pdalink: "http://m.testsite.site/test",
        amplink: "http://testsite.site/amp/test",
        media_rating: "nonadult",
        pubDate: (new Date("July 20, 69 00:20:18 GMT+00:00")).getTime(),
        author: "Test author",
        category: [
            "Технологии",
            "Наука"
        ],
        enclosure: [
            "http://testsite.site/imgs/test.jpg"
        ],
        description: "Test description",
        content_encoded: `
            Test publication text
            We have cookies!
            `
    },
    {
        title: "Another test publication",
        link: "http://testsite.site/another-test",
        ...
    },
];

Item format

| Field | Type | Description | Required? | |-------|------|-------------|-----------| |title| String | Publication title |Yes| |link| String | Publication URL on your site | Yes| |pdalink| String | Mobile version (URL) (if exists) | No | |amplink| String | AMP-version (URL) (if exists) | No | |media_rating| String | Media rating. Should take one of two values: "adult" or "nonadult | No | |pubDate| Number | Publication date in milliseconds since Unix Epoch. (Date.getTime()) | Yes | |author| String | Publication author | Yes| |category| Array (of String) | Categories of publication. Can only contain items from official documentation.| No | |enclosure| Array (of Strings) | Must contain URLs of all media objects (images, videos, etc...) used in publication text. Provide full URLs with file extension for correct MIME-type detection. | Yes| |description| String (CDATA) | Short publication description. | No | |content_encoded| String (CDATA) | Full publication text. Must be sanitized HTML (as seen in official documentation), otherwise you can use built-in parser. |Yes|

Sanitize

Sanitizing your content simply gets rid of all HTML-elements except for:

  • i
  • em
  • strong
  • a
  • img
  • video
  • figure
  • figcaption
  • media:content
  • media:description
  • media:copyright
  • span
  • strike

Be warned: it will cut out all iframe tags, usually used to embed Youtube/Vimeo/etc players. For Youtube's iframe will be transformed in simple a tag like this:

<a href="https://www.youtube.com/watch?v=_video_Id">https://www.youtube.com/watch?v=_video_Id</a>

Testing

Jest.js used for testing. Tests can be found in /tests directory.

  • npm run test - basic test-run
  • npm run test-watch - Watch files for changes and rerun tests related to changed files. (jest --watch)
  • npm run test-coverage - Displays test coverage information (jest --coverage)
  • npm run test-verbose - Test run with verbose output (jest --verbose)

PRs

Pull requests are welcome.

License

© Ismail Valiev (Konrad Molitor), 2019. Distributed under the terms of MIT License.