-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app update service): implement start command
- Loading branch information
1 parent
fe30c3b
commit b2e412e
Showing
31 changed files
with
397 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
TELEGRAM_BOT_TOKEN='6462989888:AAG3LDyEjvtwmIYv2MQs9DEhxpELhfAH8Dg' | ||
TELEGRAM_BOT_TOKEN='6462989888:AAG3LDyEjvtwmIYv2MQs9DEhxpELhfAH8Dg' | ||
DB_TYPE="better-sqlite3" | ||
DB_NAME='./dev.sqlite' | ||
DB_LOGGING=true | ||
DB_SYNCHRONIZE=true | ||
AWS_REGION='eu-north-1' | ||
AWS_ACCESS_KEY='AKIA43IVE7H4KK7ONQHK' | ||
AWS_SECRET_ACCESS_KEY='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' | ||
AWS_PUBLIC_BUCKET_NAME='chatgram' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# The name of the workflow. GitHub displays the names of your workflows under your repository's "Actions" tab. If you omit `name`, GitHub displays the workflow file path relative to the root of the repository. | ||
name: Node.js CI | ||
|
||
# This example workflow assumes that the default branch for your repository is `main`. If the default branch has a different name, edit this example and add your repository's default branch. | ||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
build: | ||
# <!-- This is a YAML comment for use in annotated code examples. --> | ||
# You can run this workflow using a different operating systems. | ||
# | ||
# The starter workflow configures jobs to run on Linux, using the GitHub-hosted `ubuntu-latest` runners. You can change the `runs-on` key to run your jobs on a different operating system. | ||
# | ||
# For example, you can use the GitHub-hosted Windows runners by specifying `runs-on: windows-latest`. Or, you can run on the GitHub-hosted macOS runners using `runs-on: macos-latest`. | ||
# | ||
# You can also run jobs in Docker containers, or you can provide a self-hosted runner that runs on your own infrastructure. For more information, see "[AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on)." | ||
runs-on: ubuntu-latest | ||
|
||
# This job uses a matrix strategy to run the job four times, once for each specified Node version. For more information, see "[AUTOTITLE](/actions/using-jobs/using-a-matrix-for-your-jobs)." | ||
strategy: | ||
matrix: | ||
node-version: [16.x, 18.x, 20.x] | ||
# | ||
steps: | ||
# This step uses the `actions/checkout` action to download a copy of your repository on the runner. | ||
- uses: actions/checkout@v3 | ||
# This step uses the `actions/setup-node` action to set up Node.js for each version indicated by the `matrix.node-version` key above. | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
# This step runs `npm ci` to install any dependencies listed in your `package.json` file. | ||
- run: npm ci | ||
# This step runs the `build` script if there is one specified under the `scripts` key in your `package.json` file. | ||
- run: npm run build --if-present | ||
# This step runs the `test` script that is specified under the `scripts` key in your `package.json` file. | ||
- run: npm test |
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Telegram } from 'telegraf'; | ||
import { Context } from '../interfaces'; | ||
import ApiClient from 'telegraf/typings/core/network/client'; | ||
|
||
type Tail<T> = T extends [unknown, ...infer U] ? U : never; | ||
|
||
type Shorthand<FName extends Exclude<keyof Telegram, keyof ApiClient>> = Tail< | ||
Parameters<Telegram[FName]> | ||
>; | ||
|
||
abstract class IReplyService { | ||
abstract sendMessage( | ||
ctx: Context, | ||
...args: Shorthand<'sendMessage'> | ||
): Promise<void>; | ||
} | ||
|
||
export { IReplyService }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { User } from '../entities'; | ||
|
||
abstract class IUserService { | ||
abstract createUser(user: User): Promise<void>; | ||
abstract create(user: User): Promise<User>; | ||
|
||
abstract updateUser(user: User): Promise<void>; | ||
abstract update(userId: number, user: User): Promise<User>; | ||
|
||
abstract findByTgId(tgId: number): Promise<User>; | ||
} | ||
|
||
export { IUserService }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Markup } from 'telegraf'; | ||
|
||
const START_REPLY_MARKUP = Markup.keyboard([ | ||
[ | ||
Markup.button.callback('🇺🇦', 'lang_ua'), | ||
Markup.button.callback('🇬🇧', 'lang_en'), | ||
Markup.button.callback('🇷🇺', 'lang_ru'), | ||
], | ||
]).reply_markup; | ||
|
||
START_REPLY_MARKUP.resize_keyboard = true; | ||
|
||
const CLEAR_REPLY_MARKUP = Markup.removeKeyboard().reply_markup; | ||
|
||
export { START_REPLY_MARKUP, CLEAR_REPLY_MARKUP }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './abstracts'; | ||
export * from './dtos'; | ||
export * from './entities'; | ||
export * from './interfaces'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Context as TelegrafContext } from 'telegraf'; | ||
import { User } from '../entities'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface Context extends TelegrafContext { | ||
session: { | ||
user?: User; | ||
lang: 'ua' | 'en' | 'ru'; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './context.interface'; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { IReplyService } from 'src/core/abstracts/reply.abstract.service'; | ||
import { TelegrafReplyService } from './telegraf-reply.service'; | ||
|
||
@Module({ | ||
providers: [ | ||
{ | ||
provide: IReplyService, | ||
useClass: TelegrafReplyService, | ||
}, | ||
], | ||
exports: [IReplyService], | ||
}) | ||
export class TelegrafReplyModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Context } from 'src/core'; | ||
import { IReplyService } from 'src/core/abstracts/reply.abstract.service'; | ||
import { | ||
ParseMode, | ||
MessageEntity, | ||
InlineKeyboardMarkup, | ||
ReplyKeyboardMarkup, | ||
ReplyKeyboardRemove, | ||
ForceReply, | ||
} from 'telegraf/typings/core/types/typegram'; | ||
import { FmtString } from 'telegraf/typings/format'; | ||
|
||
@Injectable() | ||
class TelegrafReplyService implements IReplyService { | ||
async sendMessage( | ||
ctx: Context, | ||
text: string | FmtString, | ||
extra?: Omit< | ||
{ | ||
chat_id: string | number; | ||
message_thread_id?: number; | ||
text: string; | ||
parse_mode?: ParseMode; | ||
entities?: MessageEntity[]; | ||
disable_web_page_preview?: boolean; | ||
disable_notification?: boolean; | ||
protect_content?: boolean; | ||
reply_to_message_id?: number; | ||
allow_sending_without_reply?: boolean; | ||
reply_markup?: | ||
| InlineKeyboardMarkup | ||
| ReplyKeyboardMarkup | ||
| ReplyKeyboardRemove | ||
| ForceReply; | ||
}, | ||
'chat_id' | 'text' | ||
>, | ||
): Promise<void> { | ||
await ctx.reply(text, extra); | ||
} | ||
} | ||
|
||
export { TelegrafReplyService }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './typeorm-user.module'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmUserService } from './typeorm-user.service'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { User } from 'src/core'; | ||
import { IUserService, User } from 'src/core'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([User])], | ||
exports: [TypeOrmUserService], | ||
providers: [TypeOrmUserService], | ||
providers: [ | ||
TypeOrmUserService, | ||
{ | ||
provide: IUserService, | ||
useClass: TypeOrmUserService, | ||
}, | ||
], | ||
exports: [IUserService], | ||
}) | ||
export class TypeOrmUserModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './database/database.module'; | ||
export * from './telegram/telegram.module'; | ||
export * from './user/user.module'; |
Oops, something went wrong.