Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/account/account.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
HttpCode,
HttpStatus,
} from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { ApiSecurity, ApiTags } from '@nestjs/swagger';
import { Exception } from '../utils/exception';
import { AuthGuard } from './account.guard';
import { AccountService } from './account.service';
Expand Down Expand Up @@ -67,7 +67,7 @@ export class AccountController {
}

@Get(':akey')
@ApiBearerAuth()
@ApiSecurity('custom-auth')
async findOne(@Param('akey') akey: string) {
const account = await this.accountService.findOne(akey);

Expand Down Expand Up @@ -101,7 +101,7 @@ export class AccountController {
}

@Patch(':akey/token')
@ApiBearerAuth()
@ApiSecurity('custom-auth')
async changeToken(
@Param('akey') akey: string,
@Body() changeTokenDto: ChangeTokenDto,
Expand All @@ -125,7 +125,7 @@ export class AccountController {
}

@Patch(':akey/password')
@ApiBearerAuth()
@ApiSecurity('custom-auth')
async changePassword(
@Param('akey') akey: string,
@Body() changePasswordDto: ChangePasswordDto,
Expand Down
4 changes: 2 additions & 2 deletions src/logs/logs.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { AuthGuard } from '../account/account.guard';
import { LogsGuard } from './logs.guard';
import { OwnsLog } from './decorators/owns-log.decorator';
import { SyncDto } from './dto/sync.dto';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { ApiTags, ApiSecurity } from '@nestjs/swagger';
import { LogNotExistsException } from './exceptions/log-not-exists.exception';
import { LogMissingSyncDataException } from './exceptions/log-missing-sync-data.exception';
import { TYPE } from './entities/type.entity';
Expand All @@ -35,7 +35,7 @@ import { PremiumRequiredException } from '../premium/exceptions/premium-required
@UseGuards(LogsGuard)
@UseGuards(PremiumGuard)
@ApiTags('Logs & Sync')
@ApiBearerAuth()
@ApiSecurity('custom-auth')
export class LogsController {
constructor(private readonly logsService: LogsService) {}

Expand Down
11 changes: 10 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ async function bootstrap() {
.setTitle('EVNotify API')
.setDescription('Documentation for EVNotify API')
.setVersion('3.0')
.addBearerAuth()
.addApiKey(
{
type: 'apiKey',
name: 'Authorization',
in: 'header',
description:
'Enter your authorization string in the format: <your-akey> <your-api-token>, e.g. "123456 8c6a51c82307e2b4df0c"',
},
'custom-auth',
)
.build();
const document = SwaggerModule.createDocument(app, config);

Expand Down
2 changes: 2 additions & 0 deletions src/migration/migration.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Log, LogSchema } from "../logs/schemas/log.schema";
import { LastSync, LastSyncSchema } from "../logs/schemas/last-sync.schema";
import { MigrationService } from "./migration.service";
import { MigrationAccount, MigrationAccountSchema } from "./schemas/migration-account.schema";
import { PremiumModule } from "../premium/premium.module";

@Module({
controllers: [MigrationController],
Expand All @@ -16,6 +17,7 @@ import { MigrationAccount, MigrationAccountSchema } from "./schemas/migration-ac
{ name: LastSync.name, schema: LastSyncSchema },
{ name: MigrationAccount.name, schema: MigrationAccountSchema },
]),
PremiumModule,
],
})
export class MigrationModule { };
10 changes: 5 additions & 5 deletions src/premium/premium.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BadRequestException, Body, ConflictException, Controller, Get, HttpCode, HttpStatus, InternalServerErrorException, Logger, NotFoundException, Param, Post, UseGuards } from "@nestjs/common";
import { ApiBearerAuth, ApiTags } from "@nestjs/swagger";
import { ApiSecurity, ApiTags } from "@nestjs/swagger";
import { AuthGuard } from "../account/account.guard";
import { PremiumService } from "./premium.service";
import { PremiumStatusDto } from "./dto/premium-status.dto";
Expand All @@ -19,7 +19,7 @@ export class PremiumController {
) { }

@Get(':akey')
@ApiBearerAuth()
@ApiSecurity('custom-auth')
async status(@Param('akey') akey: string): Promise<PremiumStatusDto> {
try {
const expiryDate = await this.premiumService.getExpiryDate(akey);
Expand All @@ -35,7 +35,7 @@ export class PremiumController {
}

@Post(':akey/redeem/ad')
@ApiBearerAuth()
@ApiSecurity('custom-auth')
@HttpCode(HttpStatus.OK)
async redeemAd(@Param('akey') akey: string): Promise<PremiumStatusDto> {
try {
Expand All @@ -61,7 +61,7 @@ export class PremiumController {
}

@Post(':akey/redeem/voucher/:code')
@ApiBearerAuth()
@ApiSecurity('custom-auth')
@HttpCode(HttpStatus.OK)
async redeemVoucher(@Param('akey') akey: string, @Param('code') code: string): Promise<PremiumStatusDto> {
try {
Expand All @@ -82,7 +82,7 @@ export class PremiumController {
}

@Post(':akey/redeem/subscription/:code')
@ApiBearerAuth()
@ApiSecurity('custom-auth')
@HttpCode(HttpStatus.OK)
async redeemSubscription(@Param('akey') akey: string, @Param('code') code: string) {
try {
Expand Down
4 changes: 2 additions & 2 deletions src/settings/settings.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Controller, Get, Body, Patch, Param, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { ApiSecurity, ApiTags } from '@nestjs/swagger';
import { AuthGuard } from '../account/account.guard';
import { SettingsField } from './decorators/settings-field.decorator';
import { SettingDto } from './dto/setting.dto';
Expand All @@ -10,7 +10,7 @@ import { SettingsService } from './settings.service';
@UseGuards(AuthGuard)
@UseGuards(SettingsGuard)
@ApiTags('Settings')
@ApiBearerAuth()
@ApiSecurity('custom-auth')
export class SettingsController {
constructor(private readonly settingsService: SettingsService) {}

Expand Down
3 changes: 2 additions & 1 deletion src/stations/stations.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Controller, Get, HttpException, HttpStatus, InternalServerErrorException, Param, Query, UseGuards } from "@nestjs/common";
import { ApiTags } from "@nestjs/swagger";
import { ApiSecurity, ApiTags } from "@nestjs/swagger";
import { AuthGuard } from "src/account/account.guard";
import { StationsService } from "./stations.service";
import { ListStationsFilterDto } from "./dto/list-stations.dto";
Expand All @@ -14,6 +14,7 @@ import { RouteCalculatedRecentlyException } from "./exceptions/route-calculated-
@Controller('stations')
@UseGuards(AuthGuard)
@UseGuards(PremiumGuard)
@ApiSecurity('custom-auth')
@ApiTags('Stations')
export class StationsController {
constructor(
Expand Down
3 changes: 2 additions & 1 deletion src/tripnotify/tripnotify.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BadRequestException, Body, Controller, Delete, ForbiddenException, Get, InternalServerErrorException, NotFoundException, Param, Post, UseGuards } from "@nestjs/common";
import { ApiTags } from "@nestjs/swagger";
import { ApiSecurity, ApiTags } from "@nestjs/swagger";
import { TripNotifyService } from "./tripnotify.service";
import { TripDto } from "./dto/trip.dto";
import { AuthGuard } from "src/account/account.guard";
Expand All @@ -20,6 +20,7 @@ import { TripInformationDto } from "./dto/trip-information.dto";
@Controller('trips')
@UseGuards(AuthGuard)
@UseGuards(PremiumGuard)
@ApiSecurity('custom-auth')
@ApiTags('TripNotify')
export class TripNotifyController {
constructor(
Expand Down