@knamp/content-provider

Process and store HTML content from Apache Kafka and provide via API.

Stats

StarsIssuesVersionUpdatedCreatedSize
@knamp/content-provider
111.5.33 years ago3 years agoMinified + gzip package size for @knamp/content-provider in KB

Readme

Content Provider

Process and store HTML content from Apache Kafka and provide via API.

Usage

Install via yarn

yarn install @knamp/content-provider

Then configure it and use it

import ContentProvider from "@knamp/content-provider";

(async () => {

  const server = ContentProvider({
    clientName: "transmitter-client",
    consumeFrom: "produce-topic",
    database: {
      fromMemory: true,
    },
    groupId: "transmitter-group",
    webserver: {
      port: 8855,
    },
  });

  server.on("served", (data) => {
    console.log("served", data);
  });

  server.on("missed", (data) => {
    console.log("missed", data);
  });

  server.on("stored", (data) => {
    console.log("stored", data);
  });

  server.on("deleted", (data) => {
    console.log("deleted", data);
  });

  server.on("error", (error) => {
    console.error(error);
  });

  await server.start()
})();

You can now also get entries from the database by running

import { getByPath } from "@knamp/content-provider";

(async () => {
  const path: string = ``;

  const entry = await getByPath(path);

  console.log(entry);
})();

Development

For development you need to create a local config file for the database config.local.ts in test.

It could looke like this

  export default {
    active: true,
    database: "contentprovider",
    logging: (...params) => {
      // tslint:disable-next-line
      return console.info(...params);
    },
    password: "contentprovider",
    pool: {
      idle: 10000,
      max: 5,
      min: 1,
    },
    port: 5432,
    seederStorage: "sequelize",
    username: "contentprovider",
  };

Uses

  • Sinek, consuming and producing messages to and from Apache Kafka

License

This project is under MIT.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.