Added Events
This commit is contained in:
@@ -12,7 +12,7 @@ import { EventEntity } from './events/events.entity';
|
||||
GraphQLModule.forRoot<MercuriusDriverConfig>({
|
||||
driver: MercuriusDriver,
|
||||
graphiql: true,
|
||||
autoSchemaFile: true
|
||||
autoSchemaFile: true,
|
||||
} as MercuriusDriverConfig),
|
||||
EventsModule,
|
||||
TypeOrmModule.forRoot({
|
||||
|
||||
2
src/dto
2
src/dto
Submodule src/dto updated: 669bc47276...3798232611
@@ -1,7 +1,7 @@
|
||||
import { Controller, Get, Inject, Injectable } from '@nestjs/common';
|
||||
import { Query } from '@nestjs/graphql';
|
||||
import { MyEvent } from 'src/dto/event.dto';
|
||||
import { EventsService } from './events.service';
|
||||
import { EventEntity } from './events.entity';
|
||||
|
||||
@Controller('/api/events')
|
||||
export class EventsController {
|
||||
@@ -14,8 +14,8 @@ export class EventsController {
|
||||
){}
|
||||
|
||||
@Get("/")
|
||||
@Query(()=>[MyEvent])
|
||||
async events(): Promise<MyEvent[]>{
|
||||
@Query(()=>[EventEntity])
|
||||
async events(): Promise<EventEntity[]>{
|
||||
|
||||
return await this.eventsService.getEvents();
|
||||
|
||||
|
||||
@@ -1,33 +1,45 @@
|
||||
import { EventType } from "src/dto/event.dto";
|
||||
import { Field, ObjectType } from "@nestjs/graphql";
|
||||
import { EventType, MyEvent } from "src/dto/event.dto";
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
|
||||
@ObjectType()
|
||||
@Entity()
|
||||
export class EventEntity {
|
||||
export class EventEntity implements MyEvent{
|
||||
|
||||
@Field()
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
eventname: string;
|
||||
|
||||
@Column({ type: "date" })
|
||||
@Field()
|
||||
@Column({ type: "datetime", default: "1970-01-01 00:00:00" })
|
||||
datum: Date;
|
||||
|
||||
@Field()
|
||||
@Column({ type: "enum", enum: [EventType.fotos, EventType.html, EventType.markdown, EventType.link] })
|
||||
type: EventType;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
content: string;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
minitext: string;
|
||||
|
||||
@Field({nullable: true})
|
||||
@Column({ nullable: true })
|
||||
link:string;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
foto: string;
|
||||
|
||||
@Field({nullable: true})
|
||||
@Column({ nullable: true })
|
||||
formular: number;
|
||||
}
|
||||
@@ -12,9 +12,9 @@ export class EventsService {
|
||||
|
||||
){}
|
||||
|
||||
async getEvents(): Promise<MyEvent[]> {
|
||||
async getEvents(): Promise<EventEntity[]> {
|
||||
|
||||
return (await this.eventRepository.find()) as MyEvent[];
|
||||
return (await this.eventRepository.find());
|
||||
|
||||
|
||||
|
||||
|
||||
12
src/main.ts
12
src/main.ts
@@ -5,9 +5,15 @@ import { FastifyContextConfig } from 'fastify';
|
||||
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter({
|
||||
listeningOrigin: "0.0.0.0"
|
||||
} as FastifyContextConfig));
|
||||
const fastifyAdapter=new FastifyAdapter({
|
||||
listeningOrigin: "0.0.0.0",
|
||||
crossOriginIsolated: true
|
||||
|
||||
} as FastifyContextConfig);
|
||||
|
||||
const app = await NestFactory.create<NestFastifyApplication>(AppModule, fastifyAdapter);
|
||||
|
||||
app.enableCors();
|
||||
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Ritzenbergen API')
|
||||
|
||||
Reference in New Issue
Block a user