Home
Softono
daily-api

daily-api

Open source TypeScript
466
Stars
119
Forks
6
Issues
6
Watchers
1 week
Last Commit

About daily-api

Daily API is the backend service powering the content domain of the daily.dev platform. Originally a monolith handling all extension needs, it was decomposed into smaller services, with Daily API retaining responsibility for the personalized feed and related content endpoints. The service delivers the feed users see in the daily.dev app and browser extension. Built on Node.js 22 with pnpm for dependency management, the stack includes Fastify as the web framework, Apollo for GraphQL, and TypeORM for PostgreSQL database access. The repository contains tests written with Jest, Helm charts for Kubernetes deployment, seed data for local development, and migration files for schema updates. The source code is organized into directories for common utilities, v1 API compatibility routes, cron tasks, GraphQL schema directives, TypeORM entities, database migrations, GraphQL resolvers, and pub/sub message workers. Local development requires PostgreSQL, easily started via the included docker-compose file. After running mi

Platforms

Web Self-hosted

Languages

TypeScript

Links

Daily API V2

Provide the daily.dev feed and engagement layer

Build Status License StackShare

The project started as a monolith service for everything the extension needed (thus Daily API). Safely and slowly, it was torn apart into other services to make every service have 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.

Stack

  • Node v22 (a .nvmrc is presented for nvm users).

  • pnpm 10.33.4 for managing dependencies (pinned via packageManager in package.json, activate with corepack enable && corepack prepare [email protected] --activate).

  • Fastify as the web framework

  • Apollo for GraphQL

  • TypeORM as a database layer

Project structure

  • __tests__ - There you can find all the tests and fixtures. Tests are written using jest.

  • bin - Folder with utilities and executables.

  • helm - The home of the service helm chart for easily deploying it to Kubernetes.

  • seeds - JSON files with seed data for local development.

  • src - This is obviously the place where you can find the source files.

    • common - Utility functions that are used across the project.

    • compatibility - Fastify routes to keep backwards compatibility with API v1.

    • cron - Tasks that will be deployed as cron jobs.

    • directive - GraphQL schema directives.

    • entity - Typeorm entities that are used to communicate with the database and sync its schema.

    • migration - Typeorm migrations folder to update the database schema.

    • schema - Apollo GraphQL resolvers, including types.

    • workers - Pub/Sub message handlers that are deployed as part of the background processor.

Local environment

Daily API requires a running instance of PostgreSQL, you can easily set it up using the provided docker-compose file. Check out this guide on how to install Docker Compose. Once installed, you can run docker-compose up -d and viola!

Make sure to apply the latest migrations by running: pnpm run db:migrate:latest

.env is used to set the required environment variables. It is loaded automatically by the project.

If you want some seed data, you can run: pnpm run db:seed:import

Finally, run pnpm run dev to run the service and listen on port 5000.

Caveat

Currently, there is no staging environment for Algolia, so there is no search functionality for local development.

Dependency Supply-Chain Hardening

This repo delays newly published package versions for seven days via minimumReleaseAge: 10080 in pnpm-workspace.yaml, and rejects exotic transitive dependencies (git/tarball URLs) via blockExoticSubdeps: true. Both settings are only enforced by pnpm 10+ — keep using the pinned pnpm version from package.json.

Keep pnpm-lock.yaml committed, use frozen-lockfile installs in CI, and avoid adding git or tarball dependencies unless they are reviewed explicitly. If an urgent dependency update must bypass the cooldown, add a temporary minimumReleaseAgeExclude entry in pnpm-workspace.yaml, review the package contents/provenance first, and remove the exception after the release ages out.

GraphORM

We have an internal solution to tackle the problems we have encountered along the way. The library is in its early stages, so we are continually writing the documentation to provide a better developer experience. Have a look at the link below: https://github.com/dailydotdev/daily-api/wiki/GraphORM

Want to Help?

So you want to contribute to Daily API and make an impact, we are glad to hear it. :heart_eyes:

Before you proceed, we have a few guidelines for contribution that will make everything much easier. We would appreciate it if you could dedicate the time and read them carefully:

https://github.com/dailydotdev/.github/blob/master/CONTRIBUTING.md