Giter VIP home page Giter VIP logo

fc-cache-api's Introduction

FC Cache API

Prerequisites for running the app locally

  • Unix-like environment (MacOS, Linux, WSL). Windows is not supported
  • node v12.17.0
  • npm >= v6.14.8
  • mongodb running locally

How to run

  • Go to the root folder and install dependencies (if you haven't already done so) with npm ci
  • Create a .env file at the project root (see .env.example as an example, or for the purposes of this project, rename it to .env)
  • Customize any variables you need in .env
  • Run mongodb on port 27017 (or set MONGODB_URI in .env to customize the connection string)
  • Run npm start

Viewing the API Docs

  • You can view the API docs on /api-docs

Building and running production

  • Run npm run build, you'll see the transpiled output in the dist directory
  • You can alternatively just run npm run start:prod to run in production mode (note the API docs are not served in production mode)

Testing & Coverage

  • Run npm test to run tests and collect coverage (you need to have MongoDB running)
  • You can find the collected coverage in the generated coverage directory

Config & .env

As previously mentioned, you must have a .env file in the project root with the following schema: (this is present by default)

# App operating mode, set to 'production' to run in production mode
NODE_ENV=

# Port the application will listen on
PORT=

# Connection URI for the database
MONGODB_URI=

# Max number of items in the cache
CACHE_LIMIT_COUNT=

# Default TTL for new cache entries when one is not provided, measured in seconds
DEFAULT_CACHE_ENTRY_TTL_IN_SECS

TODO

  • Set up a real logger and customize log levels
  • Add Dockerfile
  • Error handling and standardize error responses and internal codes
  • More test coverage
  • Health-check endpoint (useful when running in a containerized setup)
  • Look into codegen for the OpenAPI definition
  • Set up Dependency Injection (would be useful for the following point)
  • Abstract the data layer (what if we want to later move to an in-memory datastore? MongoDB is not the best choice for a Cache backend)
  • Sanitize inputs to prevent possible NoSQL injection (OWASP)
  • CI config
  • Pre-commit hooks (linting, type-checks)

fc-cache-api's People

Contributors

minaz912 avatar

Watchers

 avatar  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.