Skip to content

Commit

Permalink
feat: consumer ๋ถ„๋ฆฌ
Browse files Browse the repository at this point in the history
  • Loading branch information
June1010 committed Dec 20, 2022
1 parent 2c4b2f7 commit afbf118
Show file tree
Hide file tree
Showing 36 changed files with 923 additions and 14 deletions.
10 changes: 1 addition & 9 deletions noti-server/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
Body,
ConsoleLogger,
Controller,
Get,
Param,
Post,
Req,
} from '@nestjs/common';
import { Body, Controller, Post } from '@nestjs/common';
import { AppService } from './app.service';

@Controller('job')
Expand Down
9 changes: 4 additions & 5 deletions noti-server/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { AppService } from './app.service';
import { ConfigModule } from '@nestjs/config';
import { BullModule } from '@nestjs/bull';

import { DelayedConsumer } from './app.delayed.consumer';
import { ImmediateConsumer } from './app.immediate.consumer';
import { MailModule } from './mail/mail.module';
// import { DelayedConsumer } from './app.delayed.consumer';
// import { ImmediateConsumer } from './app.immediate.consumer';
// import { MailModule } from './mail/mail.module';

@Module({
imports: [
Expand All @@ -21,9 +21,8 @@ import { MailModule } from './mail/mail.module';
}),
BullModule.registerQueue({ name: 'delayed' }, { name: 'immediate' }),
CacheModule.register(),
MailModule,
],
controllers: [AppController],
providers: [AppService, DelayedConsumer, ImmediateConsumer],
providers: [AppService],
})
export class AppModule {}
8 changes: 8 additions & 0 deletions noti-worker-delayed/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
EMAIL_SERVICE=RunWithMe
EMAIL_HOST=smtp.worksmobile.com
EMAIL_PORT=587
EMAIL_USER=[email protected]
EMAIL_PW=2HMxdMVBXa68

REDIS_HOST=localhost
REDIS_PORT=6379
25 changes: 25 additions & 0 deletions noti-worker-delayed/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir : __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
35 changes: 35 additions & 0 deletions noti-worker-delayed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# compiled output
/dist
/node_modules

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
4 changes: 4 additions & 0 deletions noti-worker-delayed/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
73 changes: 73 additions & 0 deletions noti-worker-delayed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
</p>

[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->

## Description

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.

## Installation

```bash
$ npm install
```

## Running the app

```bash
# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod
```

## Test

```bash
# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov
```

## Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).

## Stay in touch

- Author - [Kamil Myล›liwiec](https://kamilmysliwiec.com)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)

## License

Nest is [MIT licensed](LICENSE).
5 changes: 5 additions & 0 deletions noti-worker-delayed/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src"
}
75 changes: 75 additions & 0 deletions noti-worker-delayed/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "noti-worker",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs-modules/mailer": "^1.8.1",
"@nestjs/bull": "^0.6.2",
"@nestjs/common": "^9.0.0",
"@nestjs/config": "^2.2.0",
"@nestjs/core": "^9.0.0",
"@nestjs/platform-express": "^9.0.0",
"bull": "^4.10.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0"
},
"devDependencies": {
"@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0",
"@types/express": "^4.17.13",
"@types/jest": "28.1.8",
"@types/node": "^16.0.0",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "28.1.3",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "28.0.8",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig-paths": "4.1.0",
"typescript": "^4.7.4"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
File renamed without changes.
23 changes: 23 additions & 0 deletions noti-worker-delayed/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Module } from '@nestjs/common';
import { DelayedConsumer } from './app.consumer';
import { ConfigModule } from '@nestjs/config';
import { BullModule } from '@nestjs/bull';
import { MailModule } from './mail/mail.module';

@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
}),
BullModule.forRoot({
redis: {
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
},
}),
MailModule,
BullModule.registerQueue({ name: 'delayed' }),
],
providers: [DelayedConsumer],
})
export class AppModule {}
33 changes: 33 additions & 0 deletions noti-worker-delayed/src/common/templates/cancel.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div width="100%"
style="display:flex; justify-content: center; background-color: rgb(240, 240, 240); padding: 30px 30px;">
<div width="100%" style="width: 100%; padding: 20px 20px; background-color: rgb(255, 255, 255);">
<div></div>
<p style="text-align: right; font-size: 0.8rem; color: rgb(156, 156, 156)">๋‚˜๋งŒ์˜ ์ฝ”์Šค๋กœ ํ•จ๊ป˜
๋‹ฌ๋ฆฌ๋Š” ๋Ÿฌ๋‹ ์ปค๋ฎค๋‹ˆํ‹ฐ</p>
<div style="width:100%; border-top: 1px solid rgb(240, 240, 240); border-bottom: 1px solid rgb(240, 240, 240);">
<h2 style="margin-bottom: 2rem;">๋ชจ์ž„์ด ์ทจ์†Œ๋˜์—ˆ์–ด์š”๐Ÿ˜ฅ๐Ÿ˜ฅ</h2>
<div style="width: 100%; display: flex; flex-direction: column; align-items: center;">
<div style="width: 100%; display: flex; justify-content: space-between;">
<p style="font-weight: 700;">๋ชจ์ž„ ์ œ๋ชฉ</p>
<p>{{title}}</p>
</div>
<div style="width: 100%; display: flex; justify-content: space-between;">
<p style="font-weight: 700;">์ง‘ํ•ฉ ์œ„์น˜</p>
<p>{{hName}}</p>
</div>
<div style="width: 100%; display: flex; justify-content: space-between;">
<p style="font-weight: 700;">์ง‘ํ•ฉ ์ผ์‹œ</p>
<p>{{startTime}}</p>
</div>
<div style="width: 100%; display: flex; justify-content: space-between;">
<p style="font-weight: 700;">์ด๊ฑฐ๋ฆฌ</p>
<p>{{pathLength}}km</p>
</div>
</div>
</div>
<div>
<p style="font-size: 0.8rem; color: rgb(156, 156, 156)">ํ–‰๋ณตํšŒ๋กœ | ์„œ์šธํŠน๋ณ„์‹œ ์ค‘๊ตฌ ๋‚จ์‚ฐ๋™2๊ฐ€
32-13 303ํ˜ธ</p>
</div>
</div>
</div>
38 changes: 38 additions & 0 deletions noti-worker-delayed/src/common/templates/recruit.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<div width="100%"
style="display:flex; justify-content: center; background-color: rgb(240, 240, 240); padding: 30px 30px;">
<div width="100%" style="width: 100%; padding: 20px 20px; background-color: rgb(255, 255, 255);">
<div></div>
<p style="text-align: right; font-size: 0.8rem; color: rgb(156, 156, 156)">๋‚˜๋งŒ์˜ ์ฝ”์Šค๋กœ ํ•จ๊ป˜
๋‹ฌ๋ฆฌ๋Š” ๋Ÿฌ๋‹ ์ปค๋ฎค๋‹ˆํ‹ฐ</p>
<div style="width:100%; border-top: 1px solid rgb(240, 240, 240); border-bottom: 1px solid rgb(240, 240, 240);">
<h2 style="margin-bottom: 2rem;">์ž ์‹œํ›„ ์ถœ๋ฐœํ•˜๋Š” ๋ชจ์ž„์ด ์žˆ์Šต๋‹ˆ๋‹ค</h2>
<div style="width: 100%; display: flex; flex-direction: column; align-items: center;">
<div style="width: 100%; display: flex; justify-content: space-between;">
<p style="font-weight: 700;">๋ชจ์ž„ ์ œ๋ชฉ</p>
<p>{{title}}</p>
</div>
<div style="width: 100%; display: flex; justify-content: space-between;">
<p style="font-weight: 700;">์ง‘ํ•ฉ ์œ„์น˜</p>
<p>{{hName}}</p>
</div>
<div style="width: 100%; display: flex; justify-content: space-between;">
<p style="font-weight: 700;">์ง‘ํ•ฉ ์ผ์‹œ</p>
<p>{{startTime}}</p>
</div>
<div style="width: 100%; display: flex; justify-content: space-between;">
<p style="font-weight: 700;">์ด๊ฑฐ๋ฆฌ</p>
<p>{{pathLength}}km</p>
</div>
</div>
<div style="width: 100%; display: flex; justify-content: center;">
<a href={{href}}
style="background-color: rgb(134, 179, 255); padding: 1rem; font-weight: 700; color: rgb(255, 255, 255); border-radius: 0.5rem; margin-bottom: 2rem; text-decoration: none;">๋ชจ์ž„
์ •๋ณด ๋ณด๋Ÿฌ๊ฐ€๊ธฐ!</a>
</div>
</div>
<div>
<p style="font-size: 0.8rem; color: rgb(156, 156, 156)">ํ–‰๋ณตํšŒ๋กœ | ์„œ์šธํŠน๋ณ„์‹œ ์ค‘๊ตฌ ๋‚จ์‚ฐ๋™2๊ฐ€
32-13 303ํ˜ธ</p>
</div>
</div>
</div>
23 changes: 23 additions & 0 deletions noti-worker-delayed/src/common/templates/signup.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div width="100%"
style="display:flex; justify-content: center; background-color: rgb(240, 240, 240); padding: 30px 30px;">
<div width="100%" style="width: 100%; padding: 20px 20px; background-color: rgb(255, 255, 255);">
<div></div>
<p style="text-align: right; font-size: 0.8rem; color: rgb(156, 156, 156)">๋‚˜๋งŒ์˜ ์ฝ”์Šค๋กœ ํ•จ๊ป˜
๋‹ฌ๋ฆฌ๋Š” ๋Ÿฌ๋‹ ์ปค๋ฎค๋‹ˆํ‹ฐ</p>
<div style="width:100%; border-top: 1px solid rgb(240, 240, 240); border-bottom: 1px solid rgb(240, 240, 240);">
<h2 style="margin-bottom: 2rem;">{{id}}๋‹˜ ๊ฐ€์ž…์„ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค.๐ŸŽ‰</h2>
<p style="margin-bottom: 2rem;">
์ง€๊ธˆ๋ถ€ํ„ฐ ์ด ๊ณ„์ •์œผ๋กœ RunWithMe๋ฅผ ์ด์šฉํ•˜์‹ค ์ˆ˜ ์žˆ์–ด์š” :)
</p>
<div style="width: 100%; display: flex; justify-content: center;">
<a href="https://runwithme.co.kr"
style="background-color: rgb(134, 179, 255); padding: 1rem; font-weight: 700; color: rgb(255, 255, 255); border-radius: 0.5rem; margin-bottom: 2rem; text-decoration: none;">RunWithMe๋ฅผ
์‹œ์ž‘ํ•ด๋ณด์„ธ์š”!</a>
</div>
</div>
<div>
<p style="font-size: 0.8rem; color: rgb(156, 156, 156)">ํ–‰๋ณตํšŒ๋กœ | ์„œ์šธํŠน๋ณ„์‹œ ์ค‘๊ตฌ ๋‚จ์‚ฐ๋™2๊ฐ€
32-13 303ํ˜ธ</p>
</div>
</div>
</div>
Loading

0 comments on commit afbf118

Please sign in to comment.