Skip to content
Draft
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
21 changes: 20 additions & 1 deletion backend/build/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ const models: TsoaRoute.Models = {
"additionalProperties": false,
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
"EventCreation": {
"dataType": "refObject",
"properties": {
"event_name": {"dataType":"string","required":true},
"event_date": {"dataType":"datetime","required":true},
"start_time": {"dataType":"string","required":true},
"end_time": {"dataType":"string","required":true},
"location": {"dataType":"string","required":true},
"latitude": {"dataType":"double","required":true},
"longitude": {"dataType":"double","required":true},
"location_name": {"dataType":"string","required":true},
"bands": {"dataType":"array","array":{"dataType":"string"},"required":true},
"description": {"dataType":"string","required":true},
"genres": {"dataType":"array","array":{"dataType":"string"},"required":true},
"ticket_price": {"dataType":"double","required":true},
},
"additionalProperties": false,
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
};
const templateService = new ExpressTemplateService(models, {"noImplicitAdditionalProperties":"throw-on-extras","bodyCoercion":true});

Expand Down Expand Up @@ -628,7 +647,7 @@ export function RegisterRoutes(app: Router) {

async function EventController_postEvent(request: ExRequest, response: ExResponse, next: any) {
const args: Record<string, TsoaRoute.ParameterSchema> = {
eventBody: {"in":"body","name":"eventBody","required":true,"ref":"Event"},
eventBody: {"in":"body","name":"eventBody","required":true,"ref":"EventCreation"},
};

// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
Expand Down
68 changes: 67 additions & 1 deletion backend/build/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,72 @@
],
"type": "object",
"additionalProperties": false
},
"EventCreation": {
"properties": {
"event_name": {
"type": "string"
},
"event_date": {
"type": "string",
"format": "date-time"
},
"start_time": {
"type": "string"
},
"end_time": {
"type": "string"
},
"location": {
"type": "string"
},
"latitude": {
"type": "number",
"format": "double"
},
"longitude": {
"type": "number",
"format": "double"
},
"location_name": {
"type": "string"
},
"bands": {
"items": {
"type": "string"
},
"type": "array"
},
"description": {
"type": "string"
},
"genres": {
"items": {
"type": "string"
},
"type": "array"
},
"ticket_price": {
"type": "number",
"format": "double"
}
},
"required": [
"event_name",
"event_date",
"start_time",
"end_time",
"location",
"latitude",
"longitude",
"location_name",
"bands",
"description",
"genres",
"ticket_price"
],
"type": "object",
"additionalProperties": false
}
},
"securitySchemes": {}
Expand Down Expand Up @@ -1027,7 +1093,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Event"
"$ref": "#/components/schemas/EventCreation"
}
}
}
Expand Down
20 changes: 17 additions & 3 deletions backend/src/Controllers/Events/EventsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@ import { Controller, Post, Body, Route } from 'tsoa';
import { createEvent } from '../../Models/Events/events.model';
import { Event } from '../../../Types/events';

@Route('events')
export interface EventCreation {
event_name: string;
event_date: Date;
start_time: string;
end_time: string;
location: string;
latitude: number;
longitude: number;
location_name: string;
bands: string[];
description: string;
genres: string[];
ticket_price: number;
}

@Route('events')
export class EventController extends Controller {
@Post('newEvent')
@Post('/newEvent')
public async postEvent(
@Body() eventBody: Event
@Body() eventBody: EventCreation
): Promise<Event> {
try {
const eventObj = eventBody;
Expand Down
3 changes: 2 additions & 1 deletion backend/src/Models/Events/events.model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import db from '../../db/db';
import { Event } from '../../../Types/events';
import { EventCreation } from 'Controllers/Events/EventsController';

export const createEvent = async (eventObj: Event) => {
export const createEvent = async (eventObj: EventCreation) => {
try {
// Create and insert the new event into the 'events' table of our database
const [newEvent] = await db<Event>('events')
Expand Down