Skip to content

Commit f5f3b82

Browse files
committed
Feat: Update docker-compose images, app.json for Heroku and add sendgrid config
1 parent 8b19f32 commit f5f3b82

File tree

10 files changed

+603
-62
lines changed

10 files changed

+603
-62
lines changed

Diff for: Procfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
server: npm run all:server
2+
worker: npm run all:worker

Diff for: README.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ Graphscript implement the following features
5050
- `npm start` - start the playground pointing for dist index at `http://localhost:3333/playground`
5151
- `npm run build` - Builds the project: Typescript to Javascript
5252

53-
## :art: Inspired on
54-
55-
Project inspired on Krakren -> https://github.com/wendelfreitas/kraken
56-
5753
## :handshake: **Contributing**
5854
If you liked the project and want to cooperate feel free to fork this repository and send Pull Requests.
5955

@@ -63,5 +59,17 @@ All kinds of contributions are very welcome and appreciated
6359
- 🐛 Find and report issues
6460
- 📥 Submit PRs to help solve issues or add features
6561

62+
## :package: Deployment
63+
64+
This project comes with a `app.json` file for heroku, that can be used to create an app on heroku from a GitHub repository.
65+
66+
After setting up the project, you can init a repository and push it on GitHub. If your repository is public, you can use the following button:
67+
68+
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/kevenleone/graphscript.git)
69+
70+
If you are in a private repository, access the following link replacing `$YOUR_REPOSITORY_LINK$` with your repository link.
71+
72+
- `https://heroku.com/deploy?template=$YOUR_REPOSITORY_LINK$`
73+
6674
## :book: License
6775
MIT license, Copyright (c) 2020 Keven Leone.

Diff for: app.json

+15-19
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
{
22
"name": "graphscript",
33
"description": "Graphscript boilerplate",
4+
"keywords": [
5+
"GraphQL",
6+
"NodeJS",
7+
"Typescript",
8+
"Javascript",
9+
"Boilerplate"
10+
],
411
"env": {
512
"AUTH_MIDDLEWARE_ENABLED": {
13+
"value": true
614
},
715
"JWT_SECRET": {
816
"generator": "secret"
917
},
10-
"MAIL_HOST": {
11-
"value": "1"
12-
},
13-
"MAIL_PASS": {
14-
"value": "1"
15-
},
16-
"MAIL_USER": {
17-
"value": "1"
18-
},
19-
"MAIL_PORT": {
20-
"value": "gitcommits.settings.production"
21-
},
2218
"MAIL_FROM": {
23-
"generator": "secret"
19+
"value": "Fred Foo 👻 <[email protected]>"
2420
}
25-
},
21+
},
2622
"formation": {
27-
"web": {
23+
"server": {
2824
"quantity": 1,
2925
"size": "free"
3026
},
@@ -39,7 +35,7 @@
3935
"options": {
4036
"version": "9.5"
4137
},
42-
"as": "DATABASE"
38+
"as": "POSTGRES"
4339
},
4440
{
4541
"plan": "heroku-redis:hobby-dev",
@@ -50,12 +46,12 @@
5046
},
5147
{
5248
"plan": "sendgrid:starter"
53-
},
54-
{
55-
"plan": "papertrail:choklad"
5649
}
5750
],
5851
"buildpacks": [
52+
{
53+
"url": "heroku/nodejs"
54+
},
5955
{
6056
"url": "heroku/nodejs"
6157
}

Diff for: docker-compose.yml

+20-9
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
version: '3'
22
services:
3-
mongodb:
4-
image: mongo:latest
5-
container_name: mongodb
6-
ports:
7-
- '27017:27017'
3+
postgres:
4+
image: postgres:latest
5+
container_name: postgres
6+
expose:
7+
- 5432
8+
environment:
9+
POSTGRES_USER: postgres
10+
POSTGRES_PASSWORD: root
11+
POSTGRES_DB: graphscript
812
volumes:
913
- './data:/data/db'
14+
redis:
15+
image: redis:latest
16+
container_name: redis
17+
ports:
18+
- '6379:6379'
1019
api:
1120
build: .
12-
container_name: graphscript-service
13-
command: npm start
21+
container_name: graphscript
22+
command: npm run dev
1423
ports:
1524
- '3333:3333'
1625
volumes:
1726
- .:/app
1827
depends_on:
19-
- mongodb
28+
- postgres
29+
- redis
2030
links:
21-
- mongodb
31+
- postgres
32+
- redis
2233

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"jsonwebtoken": "^8.5.1",
5959
"link-module-alias": "^1.2.0",
6060
"nodemailer": "^6.3.1",
61+
"nodemailer-sendgrid-transport": "^0.2.0",
6162
"pg": "^7.17.1",
6263
"reflect-metadata": "^0.1.13",
6364
"ts-node": "^8.5.0",

Diff for: src/config/defaults.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@ const {
2121
MAIL_USER,
2222
MAIL_PASS,
2323
MAIL_FROM,
24-
REDIS_HOST,
24+
REDIS_URL,
2525
REDIS_PORT,
26+
SENDGRID_USERNAME,
27+
SENDGRID_PASSWORD,
2628
} = process.env;
2729

2830
export default {
2931
CONSTANTS,
30-
REDIS_HOST,
32+
REDIS_URL,
3133
REDIS_PORT,
34+
SENDGRID_USERNAME,
35+
SENDGRID_PASSWORD,
3236
AUTH_MIDDLEWARE_ENABLED: normalizeBool(AUTH_MIDDLEWARE_ENABLED, false),
3337
RUN_PLAYGROUND: normalizeBool(RUN_PLAYGROUND, NODE_ENV !== 'production'),
3438
APP_NAME: APP_NAME || 'Graphscript',

Diff for: src/utils/Queue.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import Queue from 'bull';
2-
import { defaults, logger } from './globalMethods';
3-
const { REDIS_HOST } = defaults;
4-
5-
import * as Jobs from '../jobs';
2+
import * as Jobs from '~/jobs';
3+
import { defaults, logger } from '~/utils/globalMethods';
4+
const { REDIS_URL } = defaults;
65

76
const queues = Object.values(Jobs).map(job => {
87
const { name, data, handle, config, selfRegister = false, active = true }: any = job;
9-
const bull = new Queue(name, { redis: { host: REDIS_HOST } });
8+
const bull = new Queue(name, { redis: { host: REDIS_URL } });
109
if (selfRegister && active) bull.add(data, config);
1110
return {
1211
bull,
@@ -33,10 +32,6 @@ export default {
3332
if (active) {
3433
queue.bull.process(queue.handle);
3534

36-
queue.bull.on('active', () => {
37-
logger.info(`[${name}] | [ACTIVE]`);
38-
});
39-
4035
queue.bull.on('completed', () => {
4136
logger.info(`[${name}] | [COMPLETED]`);
4237
});

Diff for: src/utils/globalMethods.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
/* eslint-disable @typescript-eslint/camelcase */
12
import { gql } from 'apollo-server-express';
3+
import sendgridTransport from 'nodemailer-sendgrid-transport';
24

35
import { Pagination, MailConfig } from '~/interfaces';
46
import Constants from '~/utils/contants';
@@ -38,16 +40,23 @@ export function HttpError(message: string): Error {
3840
*/
3941

4042
export function MailerCredentials(): MailConfig {
41-
const { MAIL_HOST, MAIL_PORT, MAIL_USER, MAIL_PASS } = defaults;
42-
const config: MailConfig = {
43+
const { MAIL_HOST, MAIL_PORT, MAIL_USER, MAIL_PASS, SENDGRID_USERNAME, SENDGRID_PASSWORD } = defaults;
44+
if (SENDGRID_USERNAME && SENDGRID_PASSWORD) {
45+
return sendgridTransport({
46+
auth: {
47+
api_user: SENDGRID_USERNAME,
48+
api_key: SENDGRID_PASSWORD,
49+
},
50+
});
51+
}
52+
return {
4353
host: MAIL_HOST,
4454
port: MAIL_PORT,
4555
auth: {
4656
user: MAIL_USER,
4757
pass: MAIL_PASS,
4858
},
4959
};
50-
return config;
5160
}
5261

5362
/**

Diff for: types/nodemailer-sendgrid-transport/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module 'nodemailer-sendgrid-transport';

0 commit comments

Comments
 (0)