Skip to content

Commit

Permalink
always use http
Browse files Browse the repository at this point in the history
  • Loading branch information
Kona Farry committed Mar 12, 2023
1 parent 98805a9 commit 632f9de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ The "official" instance lives at [transit.alerts.social](https://transit.alerts.


# Usage
- Install `transit-fedilerts` and depdencies
- Clone the `transit-fedilerts` repo and install depdencies
- Define the agencies/services/feeds to include in `services.json`
- The structure of this file is documented in the JSON schema format at `services.schema.json` (example below)
- While the system looks for `services.json` by default, you can define a custom path with the environment variable `SERVICES_JSON`
- Compile TypeScript and run

## HTTPS/SSL
Transit Fedilerts starts up as an HTTP server when `NODE_ENV === 'production'`, but ActivityPub requires HTTPS. A reverse proxy, such as nginx, is required to handle SSL (see more below). In development, provide paths in the `SSL_CERT` and `SSL_KEY` environment variables.
Transit Fedilerts starts up as an HTTP server, but ActivityPub requires HTTPS. A reverse proxy, such as nginx, is recommended to provide SSL support. Setting `DOMAIN` to `localhost` will introduce problems; for local development, consider [ngrok](https://ngrok.com) or other options that provide temporary domain names with SSL.


## Environment Variables
Expand All @@ -27,8 +27,6 @@ Transit Fedilerts uses `dotenv` for environment variables.
| `NO_FETCH_ALERTS` | | When present, the alert fetchers won't run. Useful for testing other components |
| `PORT` | | Port to run the server on. Defaults to `8080` |
| `SERVICES_JSON` | | Custom path to a services configuration file. Defaults to `services.json` |
| `SSL_CERT` | | Path to an SSL certificate, used in development mode |
| `SSL_KEY` | | Path to an SSL public key, used in development mode |


## Example `services.json`
Expand Down
20 changes: 5 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import parseConfig from './util/parseConfigFile'
import getJobs from './alerts/makeRefreshJobs'
import { ToadScheduler } from 'toad-scheduler'
import http from 'http'
import https from 'https'
import fs from 'fs'
import { Service } from './models/config'

const app = express()
Expand Down Expand Up @@ -176,20 +174,12 @@ client.connect()
jobs.forEach(j => scheduler.addIntervalJob(j))
})
.then(() => {
if (process.env.NODE_ENV === "production") {
if (process.env.PROXY_MODE) {
const mode = parseProxyMode(process.env.PROXY_MODE)
app.set('trust proxy', mode)
}
const server = http.createServer(app)
server.listen(port, () => console.log(`Transit Fedilerts listening on port ${port}`))
} else {
const server = https.createServer({
key: process.env.SSL_KEY && fs.readFileSync(process.env.SSL_KEY),
cert: process.env.SSL_CERT && fs.readFileSync(process.env.SSL_CERT),
}, app)
server.listen(port, () => console.log(`Transit Fedilerts listening on port ${port}`))
if (process.env.PROXY_MODE) {
const mode = parseProxyMode(process.env.PROXY_MODE)
app.set('trust proxy', mode)
}
const server = http.createServer(app)
server.listen(port, () => console.log(`Transit Fedilerts listening on port ${port}`))
})
.catch(err => {
console.error(err)
Expand Down

0 comments on commit 632f9de

Please sign in to comment.