Commit c2df145b authored by nanahira's avatar nanahira

release notifier

parent f7379c0a
import { Module } from '@nestjs/common'; import { HttpModule, Module } from '@nestjs/common';
import { AppController } from './app.controller'; import { AppController } from './app.controller';
import { AppService } from './app.service'; import { AppService } from './app.service';
import { AppLogger } from './app.logger'; import { AppLogger } from './app.logger';
...@@ -6,7 +6,7 @@ import { TypeOrmModule } from '@nestjs/typeorm'; ...@@ -6,7 +6,7 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import { typeormConfig } from './config'; import { typeormConfig } from './config';
@Module({ @Module({
imports: [TypeOrmModule.forRoot(typeormConfig())], imports: [TypeOrmModule.forRoot(typeormConfig()), HttpModule],
controllers: [AppController], controllers: [AppController],
providers: [AppService, AppLogger], providers: [AppService, AppLogger],
}) })
......
import { import {
BadRequestException, BadRequestException,
ForbiddenException, ForbiddenException,
HttpService,
Injectable, Injectable,
InternalServerErrorException, InternalServerErrorException,
NotFoundException, NotFoundException,
...@@ -19,6 +20,7 @@ export class AppService { ...@@ -19,6 +20,7 @@ export class AppService {
@InjectConnection('app') @InjectConnection('app')
private db: Connection, private db: Connection,
private log: AppLogger, private log: AppLogger,
private readonly httpService: HttpService,
) { ) {
this.log.setContext('app'); this.log.setContext('app');
this.config = releaseHelperConfig; this.config = releaseHelperConfig;
...@@ -34,7 +36,22 @@ export class AppService { ...@@ -34,7 +36,22 @@ export class AppService {
if (!this.config.packagerUrl) { if (!this.config.packagerUrl) {
return; return;
} }
// todo try {
const result = await this.httpService
.post<string>(`${this.config.packagerUrl}/pack`, release, {
responseType: 'text',
})
.toPromise();
this.log.log(
`Release ${release.name} notified to ${this.config.packagerUrl}: ${result.data}`,
);
} catch (e) {
this.log.error(
`Failed to notify ${release.name} to ${
this.config.packagerUrl
}: ${e.toString()}`,
);
}
} }
async getRelease(name?: string) { async getRelease(name?: string) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment