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 { AppService } from './app.service';
import { AppLogger } from './app.logger';
......@@ -6,7 +6,7 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import { typeormConfig } from './config';
@Module({
imports: [TypeOrmModule.forRoot(typeormConfig())],
imports: [TypeOrmModule.forRoot(typeormConfig()), HttpModule],
controllers: [AppController],
providers: [AppService, AppLogger],
})
......
import {
BadRequestException,
ForbiddenException,
HttpService,
Injectable,
InternalServerErrorException,
NotFoundException,
......@@ -19,6 +20,7 @@ export class AppService {
@InjectConnection('app')
private db: Connection,
private log: AppLogger,
private readonly httpService: HttpService,
) {
this.log.setContext('app');
this.config = releaseHelperConfig;
......@@ -34,7 +36,22 @@ export class AppService {
if (!this.config.packagerUrl) {
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) {
......
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