Newsnow

repository·main·Indexed 12 days ago

https://github.com/ourongxing/newsnow

An elegant, real-time news reader providing trending updates with a clean UI. Version 0.0.41 supports GitHub OAuth for user synchronization, caching for performance, and deployment via Docker, Cloudflare Pages, or Vercel. It includes a Model Context Protocol (MCP) server implementation via the newsnow-mcp-server package and supports Cloudflare D1, Bun-sqlite, and better-sqlite3 database connectors.

Tokens
10.4K
Snippets
41
Records
52
Agent score
96%

What's inside Newsnow

  1. Deploy Newsnow using Docker

    main

    You can deploy Newsnow using Docker Compose. Ensure the docker-compose.yaml file is in the project root directory, then run:

    docker compose up

    You can also configure environment variables directly within the docker-compose.yaml file.

  2. Configure Cloudflare D1 Database support

    main

    NewsNow supports database connectors via db0.unjs.io. Cloudflare D1 is the recommended database.

    1. Create a D1 database in your Cloudflare Worker dashboard.
    2. Configure database_id and database_name in your wrangler.toml file.
    3. If wrangler.toml does not exist, rename example.wrangler.toml and update the settings.
    4. Changes will be applied upon your next deployment.
  3. Develop Newsnow locally

    main

    To develop locally, you need Node.js >= 20. Follow these steps to set up your environment:

    1. Enable corepack: corepack enable
    2. Install dependencies: pnpm i
    3. Start development server: pnpm dev

    If you wish to add new data sources, explore the shared/sources and server/sources directories.

    corepack enable
    pnpm i
    pnpm dev
  4. Configure GitHub OAuth for Newsnow

    main

    To enable GitHub login and data synchronization, you must create a GitHub App and configure the callback URL.

    1. Create a new GitHub App at GitHub Settings.
    2. No special permissions are required.
    3. Set the Callback URL to: https://your-domain.com/api/oauth/github (replace your-domain.com with your actual deployed domain).
    4. Save the generated Client ID and Client Secret for use in your environment variables.
  5. Deploy Newsnow via Cloudflare Pages

    main

    To deploy a version of Newsnow without login and caching functionality, you can use Cloudflare Pages or Vercel.

    For Cloudflare Pages specifically, use the following build settings:

    • Build command: pnpm run build
    • Output directory: dist/output/public
    pnpm run build
  6. Set up GitHub OAuth for NewsNow

    main

    To enable GitHub login and data synchronization, you must create a GitHub App:

    1. Create a new GitHub App at GitHub Settings.
    2. No special permissions are required.
    3. Set the Callback URL to: https://your-domain.com/api/oauth/github (replace your-domain.com with your actual deployment domain).
    4. Obtain your Client ID and Client Secret from the GitHub App settings.
  7. Deploy Newsnow to Cloudflare Pages

    main

    To deploy Newsnow to Cloudflare Pages, fork the repository and import it into your Cloudflare dashboard. Ensure you use the following build settings:

    • Build command: pnpm run build
    • Output directory: dist/output/public
    pnpm run build
  8. Set up local development environment

    main

    Ensure you have Node.js >= 20 installed. Follow these steps to start the development server:

    1. Enable corepack: corepack enable
    2. Install dependencies: pnpm i
    3. Start development mode: pnpm dev
    corepack enable
    pnpm i
    pnpm dev
  9. Set up Cloudflare D1 Database

    main

    Newsnow supports Cloudflare D1 for database storage.

    1. Create a D1 database in your Cloudflare Worker dashboard.
    2. Configure your wrangler.toml file with the database_id and database_name.
    3. If you do not have a wrangler.toml, rename the provided example.wrangler.toml and update the configuration.
    4. Redeploy your project to apply the changes.
  10. Set up Newsnow for local development

    main

    Local development requires Node.js version 20 or higher. Use corepack and pnpm to set up the environment:

    1. Enable corepack.
    2. Install dependencies.
    3. Run the development server.
    corepack enable
    pnpm i
    pnpm dev
  11. Configure Environment Variables

    main

    Newsnow requires several environment variables for authentication, database initialization, and caching. For local development, rename example.env.server to .env.server and populate the following keys:

    KeyDescription
    G_CLIENT_IDYour GitHub App Client ID
    G_CLIENT_SECRETYour GitHub App Client Secret
    JWT_SECRETSecret for JWT (usually the same as G_CLIENT_SECRET)
    INIT_TABLESet to true on the first run to initialize the database, then set to false
    ENABLE_CACHEBoolean to enable or disable caching
    # Github Client ID
    G_CLIENT_ID=
    # Github Client Secret
    G_CLIENT_SECRET=
    # JWT Secret, usually the same as Client Secret
    JWT_SECRET=
    # Initialize database, must be set to true on first run, can be turned off afterward
    INIT_TABLE=true
    # Whether to enable cache
    ENABLE_CACHE=true