|
| 1 | +# Setup |
| 2 | + |
| 3 | +- [Required software](#required-software) |
| 4 | + - [NodeJS](#nodejs) |
| 5 | + - [MongoDB](#mongodb) |
| 6 | +- [Optional features](#optional-features) |
| 7 | + - [Redis (optional)](#redis-optional) |
| 8 | + - [Email (optional)](#email-optional) |
| 9 | + - [Amazon s3 server (optional)](#amazon-s3-server-optional) |
| 10 | + - [hCaptcha (optional)](#hcaptcha-optional) |
| 11 | +- [Configuration](#configuration) |
| 12 | + |
| 13 | + |
| 14 | +## Required software |
| 15 | + |
| 16 | +- [NodeJS](https://nodejs.org/) |
| 17 | +- [MongoDB](https://www.mongodb.com) |
| 18 | + |
| 19 | +### NodeJS |
| 20 | + |
| 21 | +Download and install the latest LTS version of [NodeJS](https://nodejs.org/). If using a Linux based operating system, using [nvm](https://github.com/nvm-sh/nvm) is the recommended method. _Tested on NodeJS version v18.20.5_ |
| 22 | + |
| 23 | +### MongoDB |
| 24 | + |
| 25 | +Download and install the latest version of [MongoDB](https://www.mongodb.com) |
| 26 | + |
| 27 | +The server assumes that MongoDB is running as a replica set, here's how to configure a basic replica set: |
| 28 | +1. Open /etc/mongod.conf with your preferred editor. |
| 29 | + |
| 30 | +2. Add/modify the `replication` section with the following: |
| 31 | +```conf |
| 32 | +replication: |
| 33 | + replSetName: "rs0" |
| 34 | +``` |
| 35 | + |
| 36 | +3. Restart MongoDB and open a shell with `mongosh`. |
| 37 | + |
| 38 | +4. Initiate the replica set with `rs.initiate()` and check its status with `rs.status()`. |
| 39 | + |
| 40 | +## Optional features |
| 41 | + |
| 42 | +- [Redis](https://redis.io/) file caching |
| 43 | +- Email address for sending automatic emails (tested with gmail) |
| 44 | +- Amazon s3, or compatible, server for CDN methods |
| 45 | +- [hCaptcha](https://hcaptcha.com/) for website API captcha verification |
| 46 | + |
| 47 | +### Redis (optional) |
| 48 | + |
| 49 | +Redis can be used to cache files read from disk. If Redis is not configured, then an in-memory object store is used instead. |
| 50 | + |
| 51 | +### Email (optional) |
| 52 | + |
| 53 | +Events such as account creation, email verification, etc, support sending emails to users. To enable email sending, you will need to use Amazon SES. Consult the Amazon SES documentation for more details. |
| 54 | + |
| 55 | +### Amazon s3 server (optional) |
| 56 | + |
| 57 | +Certain endpoints expect URLs for static CDN assets, such as pre-rendered Mii images. An [Amazon s3](https://aws.amazon.com/s3/) or compatible server, such as [Spaces by DigitalOcean](https://www.digitalocean.com/products/spaces), [Cloudflare R2](https://www.cloudflare.com/products/r2/), or [Backblaze B2](https://www.backblaze.com/b2/docs/), can optionally be used to store and upload these assets. If an s3 server is not configured, CDN contents will be stored on disk and served from this server. See [Configuration](#configuration) for more details. |
| 58 | + |
| 59 | +### hCaptcha (optional) |
| 60 | + |
| 61 | +The Pretendo Network website uses this server as an API for querying user information. Certain endpoints are considered more secure than others, such as registration, and can optionally be protected using [hCaptcha](https://hcaptcha.com/). If hCaptcha is not configured, no endpoints on the public facing API will be protected. |
| 62 | + |
| 63 | +## Configuration |
| 64 | + |
| 65 | +Configurations are loaded through environment variables. `.env` files are supported. All configuration options will be gone over, both required and optional. There also exists an example `.env` file |
| 66 | + |
| 67 | +| Name | Description | Optional | |
| 68 | +|-----------------------------------------------|--------------------------------------------------------------------------------------------------|----------| |
| 69 | +| `PN_ACT_CONFIG_HTTP_PORT` | The HTTP port the server listens on | No | |
| 70 | +| `PN_ACT_CONFIG_MONGO_CONNECTION_STRING` | MongoDB connection string | No | |
| 71 | +| `PN_ACT_CONFIG_MONGOOSE_CONNECT_OPTIONS_PATH` | Path to a `.json` file containing Mongoose connection options | Yes | |
| 72 | +| `PN_ACT_CONFIG_REDIS_URL` | Redis URL | Yes | |
| 73 | +| `PN_ACT_CONFIG_EMAIL_SES_REGION` | Amazon SES Region | Yes | |
| 74 | +| `PN_ACT_CONFIG_EMAIL_SES_ACCESS_KEY` | Amazon SES Access Key | Yes | |
| 75 | +| `PN_ACT_CONFIG_EMAIL_SES_SECRET_KEY` | Amazon SES Access Secret | Yes | |
| 76 | +| `PN_ACT_CONFIG_EMAIL_FROM` | Email "from" address | Yes | |
| 77 | +| `PN_ACT_CONFIG_S3_ENDPOINT` | s3 server endpoint | Yes | |
| 78 | +| `PN_ACT_CONFIG_S3_ACCESS_KEY` | s3 secret key | Yes | |
| 79 | +| `PN_ACT_CONFIG_S3_ACCESS_SECRET` | s3 secret | Yes | |
| 80 | +| `PN_ACT_CONFIG_HCAPTCHA_SECRET` | hCaptcha secret (in the form `0x...`) | Yes | |
| 81 | +| `PN_ACT_CONFIG_CDN_SUBDOMAIN` | Subdomain used to serve CDN contents if s3 is disabled | Yes | |
| 82 | +| `PN_ACT_CONFIG_CDN_DISK_PATH` | File system path used to store CDN contents if s3 is disabled | Yes | |
| 83 | +| `PN_ACT_CONFIG_CDN_BASE_URL` | URL for serving CDN contents (usually the same as s3 endpoint) | No | |
| 84 | +| `PN_ACT_CONFIG_WEBSITE_BASE` | Website URL | Yes | |
| 85 | +| `PN_ACT_CONFIG_AES_KEY` | AES-256 key used for encrypting tokens | No | |
| 86 | +| `PN_ACT_CONFIG_DATASTORE_SIGNATURE_SECRET` | HMAC secret key (16 bytes in hex format) used to sign uploaded DataStore files | No | |
| 87 | +| `PN_ACT_CONFIG_GRPC_MASTER_API_KEY_ACCOUNT` | Master API key to interact with the account gRPC service | No | |
| 88 | +| `PN_ACT_CONFIG_GRPC_MASTER_API_KEY_API` | Master API key to interact with the API gRPC service | No | |
| 89 | +| `PN_ACT_CONFIG_GRPC_PORT` | gRPC server port | No | |
| 90 | +| `PN_ACT_CONFIG_STRIPE_SECRET_KEY` | Stripe API key. Used to cancel subscriptions when scrubbing PNIDs | Yes | |
| 91 | +| `PN_ACT_CONFIG_SERVER_ENVIRONMENT` | Server environment. Currently only used by the Wii U Account Settings app. `prod`/`test`/`dev` | Yes | |
0 commit comments