Code Monkey home page Code Monkey logo

daily-api's Introduction

Daily API

Service for delivering and managing Daily content

Build Status License StackShare

The project started as a monolith service for everything the extension needed (thus Daily API). Safely and slowly it was tore apart to other services to make every service has only one responsibility. The so called Daily API kept to itself the content domain. The feed you know very well is delivered from here, along with other very useful endpoints.

Technology

  • Yarn for managing dependencies.
  • Node v10.12.0 (a .nvmrc is presented for nvm users).
  • Koa as the web framework

Project structure

The project was bootstrapped with vue cli so it is very much like any other vue project but just to make sure.

  • helm - The home of the service helm chart for easily deploying it to kubernetes.
  • migrations - Knex migrations folder
  • seeds - Knex database seed files
  • src - This is obviously the place where you can find the source files.
    • src/middlewares - Koa custom middlewares.
    • src/models - Modules for interacting with the database.
    • src/routes - Endpoints of the server
    • src/workers - Background workers which listens to pub/sub messages.
  • test - There you can find all the tests and fixtures. Tests are written using mocha and chai.

Local environment

Daily API requires a running instance of MySQL, you can easily set it up using docker. Check out this guide of how to setup Daily services, you need only MySQL (step 2).

When running locally the service, you will also have to set some environment variables:

export DEFAULT_IMAGE_URL=https://storage.cloud.google.com/devkit-assets/placeholder.jpg
export DEFAULT_IMAGE_PLACEHOLDER="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QCYRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAIdpAAQAAAABAAAATgAAAAAAAABIAAAAAQAAAEgAAAABAAWQAAAHAAAABDAyMTCgAAAHAAAABDAxMDCgAQADAAAAAQABAACgAgAEAAAAAQAAAAqgAwAEAAAAAQAAAAYAAAAA/+ECz2h0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8APD94cGFja2V0IGJlZ2luPSfvu78nIGlkPSdXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQnPz4KPHg6eG1wbWV0YSB4bWxuczp4PSdhZG9iZTpuczptZXRhLyc+CjxyZGY6UkRGIHhtbG5zOnJkZj0naHR0cDovL3d3dy53My5vcmcvMTk5OS8w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AAAAAAAAAAAIDAf/aAAgBAQABBQJHjkz/xAAcEQEBAQACAwEAAAAAAAAAAAACAwEREgAEEyH/2gAIAQMBAT8BFIGNA/W+llu9LbahyZ08fkhxiZeFFNaOm0Ckkp0j5//EABwRAAMBAAIDAAAAAAAAAAAAAAECAwQAExESIf/aAAgBAgEBPwGsdL6JUnsMc6Admdc8nNnD+ft6ezJJplldJoKdgjRLoqWjp5//xAAdEAACAQQDAAAAAAAAAAAAAAABAgMREiEjABMi/9oACAEBAAY/AirQXybKSdrrQNHanhcExSbAThqlHUi0rz//xAAXEAEBAQEAAAAAAAAAAAAAAAABERAx/9oACAEBAAE/IRRs0xVxiFhHGC//2gAMAwEAAgADAAAAEGP/xAAWEQEBAQAAAAAAAAAAAAAAAAABEBH/2gAIAQMBAT8QNAUSVjBHQudd/8QAFhEBAQEAAAAAAAAAAAAAAAAAARAh/9oACAECAQE/EEkCGWNRJa8Ww//EABcQAQADAAAAAAAAAAAAAAAAAAEQESH/2gAIAQEAAT8QpeTsA40GpPBD/9k="
export DEFAULT_IMAGE_RATIO=1.7
export MYSQL_USER=root
export MYSQL_PASSWORD=12345
export MYSQL_DATABASE=devkit

export URL_PREFIX=http://localhost:4000

export PORT=5000

export GATEWAY_SECRET=topsecret

If you want some seed data you can run: npx knex seed:run

Finally run yarn watch to run the service and listen to port 5000.

Caveat

We use husky for setting pre-commit git hooks to encrypt helm values. For those without access to our Google Cloud project it will throw an exception so you can simply comment it out from package.json.

Want to Help?

So you want to contribute to Daily API and make an impact, we are glad to hear it. ๐Ÿ˜

Before you proceed we have a few guidelines for contribution that will make everything much easier. We would appreciate if you dedicate the time and read them carefully: https://github.com/dailynowco/.github/blob/master/CONTRIBUTING.md

daily-api's People

Contributors

dependabot[bot] avatar idoshamun 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.