Skip to content

Latest commit

 

History

History
133 lines (100 loc) · 4.42 KB

setup.md

File metadata and controls

133 lines (100 loc) · 4.42 KB

Setup

How to setup this project and run in your localhost or in the Vercel.

Prepare the database

Activities.next supports two types of database, SQL via Knex.js (currently tested with SQLite only in development) and Google Firestore/Firebase Firestore

Using SQL

Set ACTIVITIES_DATABASE environment variable with JSON string below by stringify it with JSON.stringify() and use the string in variable.

{
  "type": "sql",
  "client": "better-sqlite3",
  "useNullAsDefault": true,
  "connection": {
    "filename": "./dev.sqlite3"
  }
}

and run yarn migrate, this will run the migration via knex migration scripts in this directory

Using Firestore

To use Firestore, create a Firestore in the GCP console or Firebase.

Create database with production secure rule

The security rules here doesn't matter because we're going to disable it and don't allow access from client side.

Add below indexes into Firestore indexes.

  • Collection statuses, actorId Ascending, createdAt Descending
  • Collection statuses, reply Ascending, createdAt Descending
  • Collection statuses, actorId Ascending, reply Ascending, createdAt Descending
  • Collection statuses, to Arrays, actorId Ascending, createdAt Descending
  • Collection follows, actorId Ascending, status Ascending, targetActorId Ascending, createdAt Descending
  • Collection timelines, timeline Ascending, createdAt Descending
  • Collection group accountProviders, provider Ascending, accountId Ascending
  • Collection group accountProviders, provider Ascending, providerAccountId Ascending
  • Collection group attachments, actorId Ascending, createdAt Descending
  • Collection group attachments, actorId Ascending, createdAt Ascending
  • Exemptions collection group sessions, token Ascending
  • Exemptions collection group timeline, statusId Ascending
  • Exemptions collection group attachments, actorId Descending

then go to Service accounts to create a private key for SDK access.

Create firebase account key

Add the below database configuration into config.json file with the private key from the Firestore.

{
  "database": {
    "type": "firebase",
    "projectId": "Firebase project id or GCP project id",
    "credentials": {
      "client_email": "client email from json file downloads from service accounts tab",
      "private_key": "private key from json file downloads from service accounts tab"
    }
  }
}

Set default domain name to the instance

Add below configuration to tell what is the domain that will use for this ActivityPub server

{
  "host": "domain.tld"
}

Add allow email/domain list

Activities.next is still in very early development, to make sure that your instance is use only you, add the emails that allow to use the service in config.

{
  "allowEmails": ["your_email@domain.tld"]
}

Authentication

Setup the secret for the cookie and jwt session

{
  "secretPhase": "super secret for cookie and jwt session"
}

the service come with the local credentials username/password authentication however, if you want to use Github (oAuth), create personal oAuth app from Github settings.

Github settings oAuth apps list

The callback URL is https://{host}/api/auth/callback/github and click register application which Github will provider the app id and secret. Copy those value to the config.

{
  "auth": {
    "github": {
      "id": "github personal app id",
      "secret": "github personal app secret"
    }
  }
}

Start the app

To run the ActivityPub locally and talk to other federate servers, you will need a tunnel. Personally, I use Cloudflare Tunnel but any tunnel should work including ngrok

Point the tunnel to localhost at port 3000 and start the service with yarn dev then sign up your personal account at https://{host}/auth/signup then login. after this you should be able to use your ActivityPub server to follow other or post to other in Fediverse.