feat(): add sample app

This commit is contained in:
unknown 2020-12-26 16:23:54 +03:00
parent d02a52a7ae
commit 0dc981dc95
5 changed files with 35 additions and 3 deletions

View File

@ -30,7 +30,8 @@
"precommit": "lint-staged", "precommit": "lint-staged",
"prepublish:npm": "npm run build", "prepublish:npm": "npm run build",
"publish:npm": "npm publish --access public", "publish:npm": "npm publish --access public",
"test": "" "test": "",
"sample-app": "ts-node --transpile-only -r tsconfig-paths/register sample/main.ts"
}, },
"dependencies": { "dependencies": {
"telegraf": "https://github.com/telegraf/telegraf.git#develop" "telegraf": "https://github.com/telegraf/telegraf.git#develop"
@ -48,6 +49,8 @@
"prettier": "2.2.1", "prettier": "2.2.1",
"reflect-metadata": "0.1.13", "reflect-metadata": "0.1.13",
"rxjs": "6.6.3", "rxjs": "6.6.3",
"ts-node": "^9.1.1",
"tsconfig-paths": "^3.9.0",
"typescript": "4.1.2" "typescript": "4.1.2"
}, },
"peerDependencies": { "peerDependencies": {

13
sample/app.module.ts Normal file
View File

@ -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 {}

9
sample/app.update.ts Normal file
View File

@ -0,0 +1,9 @@
import { On, Update } from '../lib/decorators';
@Update()
export class AppUpdate {
@On('message')
onMessage(): void {
console.log('New message received');
}
}

7
sample/main.ts Normal file
View File

@ -0,0 +1,7 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
await NestFactory.createApplicationContext(AppModule);
}
bootstrap();

View File

@ -9,10 +9,10 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"target": "es6", "target": "es6",
"sourceMap": false, "sourceMap": false,
"baseUrl": "./",
"outDir": "./dist", "outDir": "./dist",
"rootDir": "./lib",
"skipLibCheck": true "skipLibCheck": true
}, },
"include": ["lib/**/*"], "include": ["lib/**/*", "sample/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"] "exclude": ["node_modules", "**/*.spec.ts"]
} }