Giter Club home page Giter Club logo

notifications's Introduction

Notifications App

This repo contains a toy example for a notifications app. It has a backend written in Node, and a frontend created with Create React App.

Backend

The backend is a Node server, with two endpoints and a sqlite db. The server will check for the existence of the db on startup, and will create it with a notifications table if it does not exist. Both run by default on localhost; as this is just an example project there is no option to configure different hosts or ports.

To start the backend server, from the root of the project run:

npm install
node app.js

POST endpoint

To add a notification to the system, send a POST to http://localhost:8081/notifications with the body below.

{
    "source": "my source",
    "type": "arbitrary",
    "version": 0,
    "data": {
        "message": "This is a message",
        "user": "user_id",
        "event_timestamp": 1651497606
    }
}

Each notification has a fixed set of metadata fields; in this toy example each has a timestamp ( generated by the db and indicating the ingestion time of the notification), a source field (to indicate the origin server/service/etc.), and type and version fields.

The data field represents the data payload of the notification, and is an arbitrary json. In a productized version of this toy application, downstream consumers of these notifications would be type- and version-aware, and would use versioned schemas parse the json in the data field.

In this toy example, the UI consumer is not type or version aware, and just displays the arbitrary json in the data field. However, any valid JSON may be entered substituted for the value of the data field above, and will be displayed correctly by the UI.

GET endpoint

To get a list of all notifications in the system, send a GET to http://localhost:8081/notifications. This will return a list of all notififcations, sorted by the timestamp field. Sorting, filtering, pagination, etc. are not supported as this is not a productized example.

Frontend

The frontend is a very minimal React app, When loaded, it displays the full list of all notifications in the db.

To start the front end (in development mode), from the root of the project run:

cd notifications-ui
npm install
npm start

notifications's People

Contributors

dspalmer99 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.