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