Lewati ke konten

Setup Local Development

Konten ini belum tersedia dalam bahasa Anda.

This guide will walk you through setting up a local development environment for the Blog HIMARPL website.

Prerequisites

Before installing the application, ensure you have:

  1. Node.js and npm installed
  2. Git installed
  3. Access to the following services:
    • CockroachDB account
    • Google OAuth credentials
    • Upstash account
    • PostHog account (optional)

Environment Setup Details

The project requires several environment variables to be set up in a .env file for proper functionality:

Required Services Setup

  1. CockroachDB Setup

  2. Google OAuth Setup

  3. Upstash Rate Limiting Setup

  4. Bot API Setup (optional)

Setup Steps

  1. Fork and clone the repository:

    HTTPS
    git clone https://github.com/himarplupi/blog-himarpl.git
  2. Navigate to project directory:

    Terminal window
    cd blog-himarpl
  3. Create environment variables file: Create a .env file in the root directory with the following variables:

    Terminal window
    NEXT_PUBLIC_BASE_URL="http://localhost:3000"
    NEXT_PUBLIC_BASE_PATH=""
    NEXT_BASE_URL="http://localhost:3000"
    # Database
    DATABASE_URL=
    # Authentication
    NEXTAUTH_SECRET=
    NEXTAUTH_URL="http://localhost:3000"
    GOOGLE_CLIENT_ID=
    GOOGLE_CLIENT_SECRET=
    # Rate Limiting
    UPSTASH_REDIS_REST_URL=
    UPSTASH_REDIS_REST_TOKEN=
    # PostHog (optional)
    NEXT_PUBLIC_POSTHOG_KEY=
    NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
    # Bot API (optional)
    BOT_API_URL=
    BOT_API_TOKEN=
  4. Set up remote upstream:

    HTTPS
    git remote add upstream https://github.com/himarplupi/blog-himarpl.git
  5. Install dependencies and start development server:

    Terminal window
    npm ci # Install dependencies
    npm run db:push # Push database schema to CockroachDB
    npm run dev # Start development server

    The application should now be running at http://localhost:3000.

  6. Create a new branch for your changes:

    Terminal window
    git checkout -b my-feature-branch
  7. After you are satisfied with your changes, add and commit them to your branch, then push your branch to your fork.

    Terminal window
    git add .
    git commit # Please follow the commit guidelines below
    git push -u origin my-feature-branch
  8. Create Pull Request.

Available Scripts

  • npm run dev - Starts development server with Turbo
  • npm run build - Creates production build
  • npm run start - Starts production server
  • npm run db:push - Pushes database schema to CockroachDB
  • npm run db:studio - Opens Prisma Studio for database management
  • npm run lint - Runs linting checks
  • npm run test - Runs Jest tests
  • npm run test:watch - Runs Jest tests in watch mode