Coder Social home page Coder Social logo

recurse-db's Introduction

@labsvisual/recurse-db

Introduction

This is the codebase for the pair-programming exercise by RC. This server uses @hapi/hapi as its framework of choice due to its simplicity and agility.

Considering we will not have a lot of time, unit tests cases have been removed giving way only to API (integration) test cases for the endpoints covered (get, set).

Folder Structure

.
├── __tests__
├── bin
├── config
├── lib
│   ├── key-value-store
│   └── shared
└── src
    └── api
        ├── get
        ├── set
        └── stats

__tests__

The __tests__ directory contains the test cases written using the @hapi/lab test framework and the @hapi/code assertion library.

A script has been included in package.json to run all the test cases:

  • npm t or npm test

bin

The bin directory contains recurse-db-init shell executable which will be linked by npm to recurse-db on install. To start the server, one must run ./bin/recurse-db-init.

config

This project uses confidence as its configuration provider. During the assignment, we do not need to change any existing config; but we can add more (flush interval, etc.)

This config file makes use of two directives provided by confidence:

  • $filter — to do a basic if-else based on certain environment variables; and
  • $env — to pull values from the environment.

lib

This directory contains code which is not directly executed; you can imagine this to be a list of internal packages used by this code base.

  • router.js — iterates over the src/api directory to find all the controllers and attaches them to the server object;
  • loggeer.js — a simple pino instance;
  • shared — contains a singleton-initialized instance of the KeyValue store;
  • key-value-store — a simple object-based key-value store;

This is the directory where we will do most of our work.

src

This contains execute-on-start code such as the Hapi server instance; the API definitions, etc.

  • api — every child-directory becomes an endpoint (get becomes /get/<path>); every child directory MUST contain a routes.js which exports an array of objects containing route definitions, and a controller.js which contains the handler code;
  • index.js — contains code to setup the Hapi server.

Prior Art

I did some basic research on how existing KV stores persist data;

  • Redis, for example, uses their proprietary file format;
  • we can use a similar approach since our state store is basically just a simple JS object;
  • probably flush to the file after n changes over m seconds;
  • on startup, we can check if this file exists; if so, read it and load otherwise create a new stream.

recurse-db's People

Stargazers

Shreyas Minocha avatar

Watchers

James Cloos avatar Shreyansh Pandey 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.