Skip to content

Commit eee8945

Browse files
committed
preparation for Heroku deployment
1 parent 60d032e commit eee8945

File tree

27 files changed

+283
-681
lines changed

27 files changed

+283
-681
lines changed

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: yarn workspace server start

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
},
1717
"devDependencies": {
1818
"lerna": "~3.1.4"
19-
}
19+
},
20+
"heroku-run-build-script": true
2021
}

packages/crate/demo/src/index.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import Crate from '../../src'
22

33
const crate = new Crate({
4-
// server: '436136130035843082',
5-
// channel: '436136130035843084',
6-
// shard: 'http://localhost:3000',
7-
shard: 'https://cl1.widgetbot.io',
8-
server: '299881420891881473',
9-
channel: '355719584830980096',
4+
server: 'YOUR-SERVER-ID',
5+
channel: 'YOUR-CHANNEL-ID',
6+
shard: 'http://localhost:3000',
107
// glyph: ['https://samdd.me/favicon.ico', '50%'],
118
css: `
129
&:not(.open) .button {

packages/server/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/dist/**/*
22
/data/**/*
33
!/data/README.md
4-
!/data/config.template.yml
4+
!/data/config.base.yml
5+
!/data/config.example.yml
56

67
/doc
78

packages/server/README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,25 @@ Server for hosting Discord embeds.
1313

1414
## Setting up
1515

16-
First of all rename `config.example.ts` to `config.ts`. Open it up in a text editor and replace the appropiate values.
16+
- copy `config.example.yml` to `config.yml`
17+
- edit the file as needed
1718

18-
To start a development server, simple run the following:
19+
When you can't use `config.yml` (e.g. when using automatic deployments) then you can also set some settings through environment variables:
20+
21+
```bash
22+
ADMIN_IDS=… # comma-separated list of user IDs who are admins of the bot
23+
DISCORD_TOKEN=… # your Discord Bot's Token
24+
JWT_SIGNATURE_KEY=… # add long random string here for some encryption (KEEP IT SECRET!)
25+
LOG_CHANNEL_ID=… # ID of the channel to send the server status messages to
26+
LOG_SERVER_ID=… # ID of the server to send the server status messages to
27+
```
28+
29+
## Starting
1930

2031
```bash
2132
# Install dependencies
2233
yarn
34+
2335
# Start app
2436
yarn start
2537
```

packages/server/data/config.base.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# CONFIGURATION DEFAULTS
2+
3+
# !!! DO NOT EDIT !!!
4+
# Copy `config.example.yml` to `config.yml` and edit that one instead.
5+
# You can also copy over things from here to your `config.yml` and edit them there.
6+
7+
database:
8+
dir: ./data/database/
9+
10+
discord:
11+
events: {}
12+
webhook: 'WidgetBot.io Chat'
13+
statuses: {}
14+
admins: []
15+
16+
express:
17+
port: 7000
18+
graphiql: false
19+
20+
rateLimit:
21+
windowMs: 900000
22+
max: 1000
23+
delayAfter: 100
24+
delayMs: 10
25+
26+
embed:
27+
theme:
28+
colors:
29+
primary: '#fff'
30+
accent: '#7289da'
31+
background: '#36393E'
32+
css: ''
33+
34+
config:
35+
avatar: identicon
36+
notifications: null
37+
38+
cache:
39+
graphql.messageHistory: 50
40+
graphql.messageHistoryExpiration: 20m
41+
graphql.channelsExpiration: 10s
42+
graphql.permissionsExpiration: 10s
43+
44+
log_level: info
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#################################################
2+
# Find detailed documentation over at ↓ #
3+
# https://docs.widgetbot.io/self-hosted/config/ #
4+
#################################################
5+
6+
# COPY THIS FILE BEFORE EDITING TO `config.yml`
7+
8+
database:
9+
jwt_secret: '' # TODO add long random string here for some encryption (DON'T share that string with anyone and don't add it to Git)
10+
11+
discord:
12+
token: '' # TODO add your Discord Bot's Token here
13+
14+
events:
15+
logs: ['server-id', 'channel-id'] # TODO decide where to send server activity messages to (currently only guild create/delete)
16+
status: ['server-id', 'channel-id'] # TODO decide where to send server up/down status messages to
17+
18+
statuses:
19+
- ${shard} • ${visitorCount} visitors
20+
- Discord on your website • ${shard}
21+
- ${shard} • ${accountCount} accounts
22+
- ${shard} • ${messageCount} messages
23+
- ${shard} • ${guildCount} guilds
24+
25+
admins: # TODO add your admins and remove entries you don't use
26+
- 'admin-id-1'
27+
- 'admin-id-2'

packages/server/data/config.template.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

packages/server/package.json

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@
55
"repository": "https://github.com/widgetbot-io/server.git",
66
"author": "samdd <[email protected]>",
77
"scripts": {
8-
"start": "webpack-cli --colors --config ./scripts/webpack/development --display=minimal",
8+
"start": "ts-node -r tsconfig-paths/register src/server.ts",
99
"pull": "git stash && git pull && yarn && yarn build",
10-
"build": "webpack-cli --colors --config ./scripts/webpack/production --display=minimal",
10+
"build": "rm -rf dist; tsc && ef-tspm",
1111
"test": "jest",
1212
"test:watch": "jest --watch",
1313
"doc": "typedoc --includeDeclarations --excludeExternals --externalPattern \"**/node_modules/!(@widgetbot)/**\" --ignoreCompilerErrors --out ./docs/ ./src",
1414
"precommit": "pretty-quick --staged"
1515
},
1616
"dependencies": {
17+
"@ef-carbon/tspm": "~2.2.5",
1718
"@sindresorhus/is": "~0.9.0",
1819
"@types/expect": "~1.20.3",
1920
"@types/express": "~4.11.1",
2021
"@types/express-graphql": "~0.6.1",
2122
"@types/express-winston": "~2.4.3",
2223
"@types/geoip-lite": "~1.1.29",
24+
"@types/jest": "~22.2.3",
2325
"@types/jsonwebtoken": "~7.2.7",
2426
"@types/lodash": "~4.14.108",
2527
"@types/memoizee": "~0.4.2",
@@ -34,12 +36,14 @@
3436
"country-emoji": "~1.2.0",
3537
"discord.js": "~11.3.2",
3638
"doasync": "~2.0.0",
39+
"errorhandler": "~1.5.0",
3740
"expect": "~23.1.0",
3841
"express": "~4.16.3",
3942
"express-graphql": "~0.6.12",
4043
"express-interceptor": "~1.2.0",
4144
"express-rate-limit": "~2.11.0",
4245
"express-winston": "~2.5.1",
46+
"extend": "~3.0.2",
4347
"function-pipe": "~1.2.1",
4448
"geoip-lite": "~1.2.1",
4549
"graphql": "~0.13.2",
@@ -48,7 +52,6 @@
4852
"lodash": "~4.17.10",
4953
"memoizee": "~0.4.12",
5054
"node-yaml": "~3.1.1",
51-
"on-build-webpack": "~0.1.0",
5255
"os-name": "~2.0.1",
5356
"pmx": "~1.6.4",
5457
"pretty-bytes": "~5.0.0",
@@ -59,6 +62,9 @@
5962
"socket.io-client": "~2.1.1",
6063
"source-map-support": "~0.5.6",
6164
"timestring": "~5.0.1",
65+
"ts-node": "~8.0.2",
66+
"tsconfig-paths": "~3.8.0",
67+
"typescript": "~3.3.3",
6268
"uuid": "~3.2.1",
6369
"winston": "~2.4.4",
6470
"winston-console-formatter": "~1.0.0-beta.3"
@@ -77,24 +83,16 @@
7783
},
7884
"devDependencies": {
7985
"@types/errorhandler": "~0.0.32",
80-
"@types/jest": "~22.2.3",
8186
"awesome-typescript-loader": "~5.0.0",
8287
"chalk": "~2.4.1",
83-
"clean-webpack-plugin": "~0.1.19",
84-
"errorhandler": "~1.5.0",
8588
"husky": "~0.14.3",
8689
"ifdef-loader": "~2.0.3",
8790
"javascript-obfuscator": "~0.16.0",
8891
"jest": "~23.1.0",
8992
"ncp": "~2.0.0",
90-
"nodemon-webpack-plugin": "~4.0.3",
9193
"prettier": "~1.13.4",
9294
"pretty-quick": "~1.6.0",
9395
"raw-loader": "~0.5.1",
94-
"typedoc": "~0.14.2",
95-
"typescript": "~3.3.3",
96-
"webpack": "~4.10.2",
97-
"webpack-cli": "~3.2.3",
98-
"webpack-node-externals": "~1.7.2"
96+
"typedoc": "~0.14.2"
9997
}
10098
}

packages/server/scripts/webpack/base.js

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)