Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
/ content-provider Public archive

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

License

Notifications You must be signed in to change notification settings

knamp/content-provider

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published