-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab0c378
commit 4b98d56
Showing
5 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Field, InputType, registerEnumType } from "@nestjs/graphql"; | ||
import { DestinationType } from "src/prisma/generated"; | ||
|
||
registerEnumType(DestinationType, { | ||
name: 'DestinationType', | ||
}); | ||
|
||
@InputType() | ||
export class CreateVirtualHostDto { | ||
@Field() | ||
name!: string; | ||
@Field(() => DestinationType) | ||
type!: DestinationType | ||
|
||
// @Field() | ||
// namespace!: Namespace | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Field, ID, ObjectType } from "@nestjs/graphql"; | ||
|
||
@ObjectType() | ||
export class VirtualHost { | ||
@Field(() => ID) | ||
id: string | undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { VirtualHostResolver } from './virtual-host.resolver'; | ||
import { VirtualHostService } from './virtual-host.service'; | ||
|
||
@Module({ | ||
providers: [VirtualHostResolver, VirtualHostService], | ||
exports: [VirtualHostService], | ||
}) | ||
export class VirtualHostModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql'; | ||
import { CreateVirtualHostDto } from './virtual-host.dto'; | ||
import { VirtualHost } from './virtual-host.model'; | ||
import { VirtualHostService } from './virtual-host.service'; | ||
|
||
@Resolver(() => VirtualHost) | ||
export class VirtualHostResolver { | ||
constructor(private readonly service: VirtualHostService) { } | ||
|
||
@Query(() => VirtualHost) | ||
async virtualHosts(): Promise<VirtualHost[]> { | ||
return this.service.getVirtualHosts(); | ||
} | ||
|
||
@Mutation(() => VirtualHost) | ||
async createVirtualHost(@Args('payload') payload: CreateVirtualHostDto): Promise<VirtualHost> { | ||
return this.service.createVirtualHost(payload); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { PrismaService } from 'src/prisma/prisma.service'; | ||
import type { CreateVirtualHostDto } from './virtual-host.dto'; | ||
import type { VirtualHost } from './virtual-host.model'; | ||
|
||
@Injectable() | ||
export class VirtualHostService { | ||
constructor(private readonly prisma: PrismaService) { } | ||
|
||
async getVirtualHosts(): Promise<VirtualHost[]> { | ||
return this.prisma.virtualHost.findMany(); | ||
} | ||
|
||
async createVirtualHost(payload: CreateVirtualHostDto): Promise<VirtualHost> { | ||
console.log(payload) | ||
return Promise.reject('Not implemented'); | ||
} | ||
} |