- Read: Contributing Guidelines
- Install all of the following:
- SQL Server Express or your favorite SQL technology that TypeORM supports.
- Node v10+
- TypeORM CLI
- Clone this repo
- Run
npm install
- Set up your .env / dotenv file
- Set up your local database
- 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
- The Troubleshooting section
- Our GitHub project's issues
- If all else fails, report an issue here. Sorry we couldn't get you fixed sooner 😢
Make a file called ".env
" in project root, with these contents:
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"
- Create a local SQL Database named
EggParty
- e.g.
CREATE DATABASE EggParty;
- e.g.
- Make sure your local database server has these features enabled:
- Create a local SQL admin with the credentials in your
.env
file - Run
npm run migration:run
to set up the Egg Party schema in your local database.
Something out of date? Click here to report an issue!
In order to run locally against Slack, you'll need:
- A Slack Workspace to test in (create one here), and
- A Slack App (create one here)
- You should be taken to a Basic Information view after creating your app.
- Scroll down to App Credentials, and copy these credentials to the
.env
file you created earlier:- Client ID >
SLACK_CLIENT_ID
- Client Secret >
SLACK_CLIENT_SECRET
- Signing Secret >
SLACK_SIGNING_SECRET
- Client ID >
- From the Features sidebar, go to Oauth & Permissions.
- For now, add a Redirect URL of
https://www.egg-party.com/api/v1/slack/oauth/redirect
. - Down in the Scopes view, add the following scopes:
channels:history
reactions:read
im:history
im:write
chat:write
- From the Features sidebar, go to Event Subscriptions.
- Turn Events on.
- For now, put a Request URL of
https://www.egg-party.com/api/v1/slack/events
. - Down in the Subscribe to Bot Events view, add the following Bot User Events:
message.channels
message.im
reaction_added
- From the Features sidebar, go to Interactive Components.
- Turn Interactivity on.
- For now, put a Request URL of
https://www.egg-party.com/api/v1/slack/interactions
.
- In a shell, run
npm start
to run your local API. - In another shell, run
npm run tunnel
to tunnel your local traffic to a public URL. - The URL printed by
ngrok
is a URL that Slack can use to interact with your local environment. - From the Features sidebar, go to Oauth & Permissions.
- Replace the Redirect URL you added earlier with
https://{{ngrokUrl}}/api/v1/slack/oauth/redirect
- From the Features sidebar, go to Event Subscriptions.
- Replace the Request URL you put earlier with
https://{{ngrokUrl}}/api/v1/slack/events
- From the Features sidebar, go to Interactive Components.
- Replace the Request URL you put earlier with
https://{{ngrokUrl}}/api/v1/slack/interactions
- From the Features sidebar, go to Manage Distribution.
- 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.
- This should create a
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
|
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
)
Failed to connect to localhost:1433 - Could not connect (sequence)
- Cause: TCP is not enabled or the SQL Server Browser Service is not running (Related: typeorm#2333)
- Making changes to the Guide Book? Use the Guide Book Template!