From 0dc981dc9525703a164509b4c3bb14c5f61cac25 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 26 Dec 2020 16:23:54 +0300 Subject: [PATCH] feat(): add sample app --- package.json | 5 ++++- sample/app.module.ts | 13 +++++++++++++ sample/app.update.ts | 9 +++++++++ sample/main.ts | 7 +++++++ tsconfig.json | 4 ++-- 5 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 sample/app.module.ts create mode 100644 sample/app.update.ts create mode 100644 sample/main.ts diff --git a/package.json b/package.json index 9756227..d842c0e 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "precommit": "lint-staged", "prepublish:npm": "npm run build", "publish:npm": "npm publish --access public", - "test": "" + "test": "", + "sample-app": "ts-node --transpile-only -r tsconfig-paths/register sample/main.ts" }, "dependencies": { "telegraf": "https://github.com/telegraf/telegraf.git#develop" @@ -48,6 +49,8 @@ "prettier": "2.2.1", "reflect-metadata": "0.1.13", "rxjs": "6.6.3", + "ts-node": "^9.1.1", + "tsconfig-paths": "^3.9.0", "typescript": "4.1.2" }, "peerDependencies": { diff --git a/sample/app.module.ts b/sample/app.module.ts new file mode 100644 index 0000000..e35a9f4 --- /dev/null +++ b/sample/app.module.ts @@ -0,0 +1,13 @@ +import { Module } from '@nestjs/common'; +import { TelegrafModule } from '../lib'; +import { AppUpdate } from './app.update'; + +@Module({ + imports: [ + TelegrafModule.forRoot({ + token: '1467731595:AAHCvH65H9VQYKF9jE-E8c2rXsQBVAYseg8', + }), + ], + providers: [AppUpdate], +}) +export class AppModule {} diff --git a/sample/app.update.ts b/sample/app.update.ts new file mode 100644 index 0000000..a0dc748 --- /dev/null +++ b/sample/app.update.ts @@ -0,0 +1,9 @@ +import { On, Update } from '../lib/decorators'; + +@Update() +export class AppUpdate { + @On('message') + onMessage(): void { + console.log('New message received'); + } +} diff --git a/sample/main.ts b/sample/main.ts new file mode 100644 index 0000000..42c2fa5 --- /dev/null +++ b/sample/main.ts @@ -0,0 +1,7 @@ +import { NestFactory } from '@nestjs/core'; +import { AppModule } from './app.module'; + +async function bootstrap() { + await NestFactory.createApplicationContext(AppModule); +} +bootstrap(); diff --git a/tsconfig.json b/tsconfig.json index e47f6d2..921d963 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,10 +9,10 @@ "experimentalDecorators": true, "target": "es6", "sourceMap": false, + "baseUrl": "./", "outDir": "./dist", - "rootDir": "./lib", "skipLibCheck": true }, - "include": ["lib/**/*"], + "include": ["lib/**/*", "sample/**/*"], "exclude": ["node_modules", "**/*.spec.ts"] }