mirror of
https://github.com/PhoenixTwoFive/karaoqueue.git
synced 2025-05-20 03:21:47 +02:00
Add empty Controllers
This commit is contained in:
parent
c5e8ae0649
commit
c6c6b5da00
@ -0,0 +1,15 @@
|
||||
import { Post, BodyParam, Body, Res, Req, JsonController, UseBefore, Get, CookieParam } from "routing-controllers";
|
||||
import { UserCredential } from "../models/usercredential.model";
|
||||
|
||||
@JsonController("/auth")
|
||||
export class AuthenticationController {
|
||||
@Post("/login")
|
||||
doLogin(@Body() usercredential: UserCredential, @Res() res: any) {
|
||||
return "//TODO login";
|
||||
}
|
||||
|
||||
@Get("/logout")
|
||||
doLogout() {
|
||||
return "//TODO logout";
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
import { Controller, Get, Res, Post, Delete, Patch, Req } from "routing-controllers";
|
||||
|
||||
|
||||
@Controller("/queue")
|
||||
export class QueueController {
|
||||
|
||||
/*
|
||||
* Fetch entry Queue content
|
||||
*/
|
||||
@Get()
|
||||
getQueue(@Req() req: any, @Res() res: any) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify({ placeholder: "//TODO fetch" }));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add entry to Queue
|
||||
*/
|
||||
@Post()
|
||||
addEntry(@Req() req: any, @Res() res: any) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify({ placeholder: "//TODO add" }));
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
@Delete()
|
||||
clearQueue(@Req() req: any, @Res() res: any) {
|
||||
return "//TODO clear";
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
@Get("/:entry:id")
|
||||
getEntry(@Req() req: any, @Res() res: any) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify({ placeholder: "//TODO get" }));
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
@Patch("/:entry_id")
|
||||
editEntry(@Req() req: any, @Res() res: any) {
|
||||
return "//TODO edit"
|
||||
}
|
||||
|
||||
@Delete("/:entry_id")
|
||||
deleteEntry(@Req() req: any, @Res() res: any) {
|
||||
return "//TODO delete"
|
||||
}
|
||||
}
|
39
backend/karaoqueue-backend/src/controllers/rpc.controller.ts
Normal file
39
backend/karaoqueue-backend/src/controllers/rpc.controller.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { Controller, Get, Param, QueryParam } from "routing-controllers";
|
||||
|
||||
@Controller("/rpc")
|
||||
export class RpcController {
|
||||
@Get("/start_event")
|
||||
doStartEvent() {
|
||||
return "//TODO start_event"
|
||||
}
|
||||
|
||||
@Get("/end_event")
|
||||
doEndEvent() {
|
||||
return "//TODO end_event"
|
||||
}
|
||||
|
||||
@Get("/enable_registration")
|
||||
doEnableRegistration() {
|
||||
return "//TODO enable_registration"
|
||||
}
|
||||
|
||||
@Get("/disable_registration")
|
||||
doDisableRegistration() {
|
||||
return "//TODO disable_registration"
|
||||
}
|
||||
|
||||
@Get("/get_playstats")
|
||||
doGetPlaystats() {
|
||||
return "//TODO get_playstats"
|
||||
}
|
||||
|
||||
@Get("/download_playstats")
|
||||
doDownloadPlaystats() {
|
||||
return "//TODO download_playstats"
|
||||
}
|
||||
|
||||
@Get("/entry_fulfilled")
|
||||
doEntryFulfilled(@QueryParam("entry_id") entryId: string) {
|
||||
return `//TODO entry_fulfilled. entry_id: ${entryId}`
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
import { Get, QueryParam, JsonController, Put } from "routing-controllers";
|
||||
|
||||
@JsonController("/songs")
|
||||
export class SongController {
|
||||
@Get()
|
||||
searchSongs(@QueryParam("query") query: string, @QueryParam("limit") limit: number) {
|
||||
return {result: "//TODO search"}
|
||||
}
|
||||
|
||||
@Put()
|
||||
updateSongs() {
|
||||
return "//TODO update"
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
import { JsonController, Get } from "routing-controllers";
|
||||
|
||||
@JsonController()
|
||||
export class StatisticsController {
|
||||
@Get()
|
||||
getStatistics() {
|
||||
return "//TODO statistics"
|
||||
}
|
||||
}
|
@ -1,13 +1,15 @@
|
||||
import express = require("express");
|
||||
import "reflect-metadata";
|
||||
import { createExpressServer } from "routing-controllers";
|
||||
import { QueueController } from "./controllers/queue.controller";
|
||||
import { SongController } from "./controllers/songs.controller";
|
||||
import { StatisticsController } from "./controllers/statistics.controller";
|
||||
import { AuthenticationController } from "./controllers/auth.controller";
|
||||
import { RpcController } from "./controllers/rpc.controller";
|
||||
|
||||
const app: express.Application = express();
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Hello World!');
|
||||
// tslint:disable-next-line: no-console
|
||||
console.log(req.headers["user-agent"]);
|
||||
const app = createExpressServer({
|
||||
routePrefix: "/api",
|
||||
cors: true,
|
||||
controllers: [QueueController, SongController, StatisticsController, AuthenticationController, RpcController]
|
||||
});
|
||||
app.listen(3000, () => {
|
||||
// tslint:disable-next-line: no-console
|
||||
console.log('App is listening on port 3000!');
|
||||
});
|
||||
|
||||
app.listen(3000);
|
@ -0,0 +1,4 @@
|
||||
export interface UserCredential {
|
||||
username: string,
|
||||
password: string
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user