Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cakekindel/egg-party

A new way to celebrate your teammates in Slack, and have fun doing it!
https://github.com/cakekindel/egg-party

culture egg-party nestjs slack slack-apps social teammates typeorm

Last synced: 8 days ago
JSON representation

A new way to celebrate your teammates in Slack, and have fun doing it!

Awesome Lists containing this project

README

        

# Egg Party ๐Ÿฅš๐ŸŽ‰

### Egg party is a Slack App for thanking teammates, raising chickens, and having a rowdy ol' time

---

![GitHub top language](https://img.shields.io/github/languages/top/cakekindel/egg-party)
[![Azure DevOps builds](https://img.shields.io/azure-devops/build/egg-party/466bd0c0-cb88-4264-9c33-42defabff549/4)](https://dev.azure.com/egg-party/egg-party-api/_build?definitionId=4)
[![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/egg-party/466bd0c0-cb88-4264-9c33-42defabff549/4)](https://dev.azure.com/egg-party/egg-party-api/_dashboards/dashboard/663d6429-94b5-48ec-b08c-829ef80489aa)
[![Greenkeeper badge](https://badges.greenkeeper.io/cakekindel/egg-party.svg)](https://greenkeeper.io/)

[![GitHub issues](https://img.shields.io/github/issues/cakekindel/egg-party?color=%2360bec4)](https://github.com/cakekindel/egg-party/issues)
[![Good First Issues](https://img.shields.io/github/labels/cakekindel/egg-party/tag%3Agood%20first%20issue)](https://github.com/cakekindel/egg-party/labels/tag%3Agood%20first%20issue)
[![Features](https://img.shields.io/github/labels/cakekindel/egg-party/type%3Afeature)](https://github.com/cakekindel/egg-party/labels/type%3Afeature)
[![Bugs](https://img.shields.io/github/labels/cakekindel/egg-party/type%3Abug)](https://github.com/cakekindel/egg-party/labels/type%3Abug)

[![CII Best Practices Tiered Percentage](https://img.shields.io/cii/percentage/3447)](https://bestpractices.coreinfrastructure.org/en/projects/3447)
![GitHub](https://img.shields.io/github/license/cakekindel/egg-party)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcakekindel%2Fegg-party.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcakekindel%2Fegg-party?ref=badge_shield)

### Table of Contents
---
- [**Want to contribute?**](#want-to-contribute)
- [**Setup**](#setup)
- [**Set up your local .env / dotenv file**](#local-environment-config)
- [**Set up your local SQL Database**](#sql-database-setup)
- [**Set up a Slack App for testing in Slack**](#sql-database-setup)
- [**Slack Setup**](#slack-setup)
- [**Slack App Settings**](#slack-app-settings)
- [**Using your Local API with your Slack App**](#using-your-local-api-with-your-slack-app)
- [**Scripts**](#scripts)
- [**Debugging**](#debugging)
- [**Visual Studio Code**](#visual-studio-code)
- [**Common Errors**](#common-errors)
- [**Helpful Links**](#helpful-links)


### **Want to contribute?**
---

* **Read**: [Contributing Guidelines](.github/CONTRIBUTING.md)
* **Install** all of the following:
- [SQL Server Express][sql-server-download] or your favorite SQL technology that [TypeORM supports][typeorm-connection-types].
- [Node v10+][node-download]
- [TypeORM CLI][typeorm-install]


### **Setup**
---

1. Clone this repo
1. Run `npm install`
1. Set up your [.env / dotenv file](#local-environment-config)
1. Set up your [local database](#sql-database-setup)
1. In a shell in Egg Party, run `npm test` to build the project
and run the unit tests.
* If your tests run and pass, WOO! ๐ŸŽ‰๐Ÿ’ƒ
* If they don't, check:
- That you [**installed everything**](#want-to-contribute)
- The [**Troubleshooting**](#common-errors) section
- Our [**GitHub project's issues**][issues-list]
* If all else fails, [report an issue here][report-issue].
Sorry we couldn't get you fixed sooner ๐Ÿ˜ข

#### **Local Environment Config**
Make a file called "`.env`" in project root, with these contents:
```python
ENVIRONMENT="Local"

SLACK_CLIENT_ID="" # CLIENT ID HERE
SLACK_CLIENT_SECRET="" # CLIENT SECRET HERE
SLACK_SIGNING_SECRET=""# SIGNING SECRET HERE

# For more information see https://typeorm.io/#/connection-options/common-connection-options
TYPEORM_CONNECTION="" # if you're using SQL Server, use "mssql"
TYPEORM_DATABASE="EggParty"
TYPEORM_ENTITIES="./dist/src/db/entities/*.entity.js"
TYPEORM_MIGRATIONS="./dist/src/db/migrations/*.js"
TYPEORM_HOST="localhost"
TYPEORM_USERNAME="admin"
TYPEORM_PASSWORD="password"
```

#### **SQL Database Setup**

1. Create a local SQL Database named `EggParty`
* e.g. `CREATE DATABASE EggParty;`
1. Make sure your local database server has these features enabled:
* [SQL Server Auth][sql-server-auth-mode]
* [TCP/IP][sql-enable-tcp]
1. [Create a local SQL admin][create-sql-admin] with the credentials in your `.env` file
1. Run `npm run migration:run` to set up the Egg Party schema in your local database.


### **Slack Setup**
---

**[Something out of date? Click here to report an issue!][report-issue]**

In order to run locally against Slack, you'll need:
- A Slack Workspace to test in (_[create one here][slack-create-workspace]_), and
- A Slack App (_[create one here][slack-manage-apps]_)

#### Slack App Setup

1. You should be taken to a **Basic Information** view after creating your app.
1. Scroll down to **App Credentials**, and copy these credentials to the `.env` file you [created earlier](#local-configuration-files):
- **Client ID** > `SLACK_CLIENT_ID`
- **Client Secret** > `SLACK_CLIENT_SECRET`
- **Signing Secret** > `SLACK_SIGNING_SECRET`
1. From the **Features** sidebar, go to **Oauth & Permissions**.
1. For now, add a **Redirect URL** of `https://www.egg-party.com/api/v1/slack/oauth/redirect`.
1. Down in the **Scopes** view, add the following scopes:
- `channels:history`
- `reactions:read`
- `im:history`
- `im:write`
- `chat:write`
1. From the **Features** sidebar, go to **Event Subscriptions**.
1. Turn **Events** on.
1. For now, put a **Request URL** of `https://www.egg-party.com/api/v1/slack/events`.
1. Down in the **Subscribe to Bot Events** view, add the following **Bot User Events**:
- `message.channels`
- `message.im`
- `reaction_added`
1. From the **Features** sidebar, go to **Interactive Components**.
1. Turn **Interactivity** on.
1. For now, put a **Request URL** of `https://www.egg-party.com/api/v1/slack/interactions`.

#### Using your Local API with your Slack App

1. In a shell, run `npm start` to run your local API.
1. In another shell, run `npm run tunnel` to tunnel your local traffic to a public URL.
1. The URL printed by `ngrok` is a URL that Slack can use to interact with your local environment.
1. From the **Features** sidebar, go to **Oauth & Permissions**.
1. Replace the Redirect URL you added earlier with `https://{{ngrokUrl}}/api/v1/slack/oauth/redirect`
1. From the **Features** sidebar, go to **Event Subscriptions**.
1. Replace the Request URL you put earlier with `https://{{ngrokUrl}}/api/v1/slack/events`
1. From the **Features** sidebar, go to **Interactive Components**.
1. Replace the Request URL you put earlier with `https://{{ngrokUrl}}/api/v1/slack/interactions`
1. From the **Features** sidebar, go to **Manage Distribution**.
1. Click the **Embeddable Slack Button** to install your app to your workspace.
* This should create a `slack_team` entry in your database,
and redirect you to Egg Party in your Slack Workspace.


### **Scripts**
---


Running



npm start

npm run serve



Run the API locally, hot reload when you make typescript changes


Testing



npm test

npm run test:single-run



Build & run all unit tests





npm run test:watch


Run all unit tests & re-run when you make changes


Utilities


npm run tunnel


Tunnel your local traffic to a public URL using `ngrok`.

Use this to run locally against Slack.


Style / Linting


npm run style:fix


Formats your local codebase to the Google Typescript Style


Database


npmย runย migration:generate


Generate a TypeORM migration file based on changes made to entities since the last migration was made


Usage note: you must pass the migration script a name for the migration

e.g. npm run migration:generate -- -n AddCreatedDateColumn





npm run migration:run


Runs migrations against the database specified in .env


### **Debugging**
---

#### Visual Studio Code

Run the command `Debug: Start Debugging` by pressing `F5`, by searching in the command palette (`F1`),
or from the Debug panel (`Ctrl/Cmd + Shift + D`)


### **Common Errors**
---
* `Failed to connect to localhost:1433 - Could not connect (sequence)`
* **Cause**: [TCP is not enabled][sql-enable-tcp] or
the [SQL Server Browser Service][sql-enable-server-browser] is not running
*(Related: [typeorm#2333][typeorm#2333])*


### **Helpful Links:**
---
* Making changes to the Guide Book? Use the [Guide Book Template][guide-book-template]!

[issues-list]: https://github.com/cakekindel/egg-party/issues
[report-issue]: https://github.com/cakekindel/egg-party/issues/new
[sql-server-download]: https://www.microsoft.com/en-us/sql-server/sql-server-downloads
[node-download]: https://nodejs.org/en/
[typeorm-connection-types]: https://typeorm.io/#/connection-options/common-connection-options
[typeorm-install]: https://github.com/typeorm/typeorm/blob/master/docs/using-cli.md

[sql-server-auth-mode]: https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/change-server-authentication-mode?view=sql-server-2017
[create-sql-admin]: https://www.godaddy.com/help/create-an-admin-user-for-microsoft-sql-server-19032
[sql-enable-tcp]: https://www.habaneroconsulting.com/stories/insights/2015/tcpip-is-disabled-by-default-in-microsoft-sql-server-2014
[sql-enable-server-browser]: https://www.godaddy.com/help/enable-the-sql-server-browser-service-19117
[typeorm#2333]: https://github.com/typeorm/typeorm/issues/2133

[slack-create-workspace]: https://slack.com/create
[slack-manage-apps]: https://api.slack.com/apps

[gts-url]: https://github.com/google/gts

[guide-book-template]: https://bit.ly/2NypQvF