Skip to content

Commit

Permalink
Merge pull request #41 from berkmancenter/dev
Browse files Browse the repository at this point in the history
Merge release 3.1.0 to main
  • Loading branch information
jsdiaz authored Sep 6, 2024
2 parents 0791245 + de60e42 commit b197b95
Show file tree
Hide file tree
Showing 66 changed files with 30,584 additions and 3,152 deletions.
7 changes: 4 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ JWT_SECRET=thisisasamplesecret
JWT_ACCESS_EXPIRATION_MINUTES=30
# Number of days after which a refresh token expires
JWT_REFRESH_EXPIRATION_DAYS=30

# Secret used to encrypt generated passwords
AUTH_TOKEN_SECRET=6dba17141c3ce22d67f9ebdb937644e617f999b8
JWT_RESET_PASSWORD_EXPIRATION_MINUTES=120

# SMTP configuration options for the email service
# For testing, you can use a fake SMTP service like Ethereal: https://ethereal.email/create
Expand All @@ -22,3 +20,6 @@ SMTP_PORT=587
SMTP_USERNAME=email-server-username
SMTP_PASSWORD=email-server-password
EMAIL_FROM=[email protected]

# This is used to build links for the reset password and channel archive emails
APP_HOST=http://localhost:3000
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
# Threads server
# Threads API

## Description

This is the backend API for [berkmancenter/threads_client](https://github.com/berkmancenter/threads_client).

## Installation

### Using Docker

- Create file `.env.local` and copy contents of `.env.example`. Feel free to change the port number in the file but make sure to make changes on fronend env file to reflect the correct port number. Also, if you change the port number, make sure to change the port numbers in `docker-compose.yml` as well. The port number for socket io is defined implicitly in the app as `5555` and can be changed by making change to file `/src/websockets/index.js`
- Edit `docker-compose.dev.yml` file to add the following block to the `node-app` service

```
env_file:
- .env.local
```

the full block should then look like this:

```
services:
node-app:
env_file:
- .env.local
```

- Run below docker compose command to start the server

```
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build
```

## Running locally

1. Start by copying `.env.example` to `.env`.
2. Install `mongodb`
3. Run MongoDB with `mongod`
4. Install all dependencies with `npm install`.
5. Run `npm run dev` to serve the API locally.

## Tests

### Unit and integration tests

Unit and integration tests can be run with `npm run test`, and a coverage report can be seen with `npm run coverage`.

### Stress tests

Stress tests can be run from the client repo in the [k6 directory](https://github.com/berkmancenter/threads_client/blob/main/k6).

## Deployment

1. Pull the latest code from Github (currently the dev branch)
2. Configure .env and install dependencies
3. Run `npm run start` to serve the API with [PM2](https://pm2.keymetrics.io/docs/usage/process-management/)
4 changes: 3 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ version: '3'
services:
node-app:
container_name: node-app-dev
command: yarn dev -L
command: yarn && yarn dev -L
env_file:
- .env.local
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
- node-network

mongodb:
platform: linux/x86_64
image: mongo:3.2.19
ports:
- '27017:27017'
Expand Down
6 changes: 3 additions & 3 deletions ecosystem.config.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"apps": [
{
"name": "app",
"name": "threads-api",
"script": "src/index.js",
"instances": 1,
"exec_mode": "cluster",
"instances": "max",
"autorestart": true,
"watch": false,
"time": true,
"env": {
"NODE_ENV": "production"
}
Expand Down
Loading

0 comments on commit b197b95

Please sign in to comment.