mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2026-04-28 19:27:38 +02:00
added / fixed some types
This commit is contained in:
@@ -1,17 +1,66 @@
|
||||
import { Response } from 'express'
|
||||
|
||||
import logger from '../../../utils/logger'
|
||||
import utils from '../../../utils/utils'
|
||||
import { Request, SubmoduleData } from '../../../types/basicTypes'
|
||||
|
||||
interface Categories {
|
||||
[key: string]: {
|
||||
name: string
|
||||
color: string
|
||||
}
|
||||
}
|
||||
|
||||
enum CardState {
|
||||
TODO = 'todo',
|
||||
INPROGRESS = 'inprogress',
|
||||
TESTING = 'testing',
|
||||
DONE = 'done',
|
||||
INPROD = 'inprod',
|
||||
NOTPOSSIBLE = 'notpossible',
|
||||
}
|
||||
|
||||
interface Card {
|
||||
id: number
|
||||
name: string
|
||||
description: string
|
||||
category: string
|
||||
points: number
|
||||
state: CardState
|
||||
votes: number[]
|
||||
}
|
||||
|
||||
type Columns = {
|
||||
[key in CardState]: {
|
||||
name: string
|
||||
clickable: boolean
|
||||
}
|
||||
}
|
||||
|
||||
interface Groups {
|
||||
[key: string]: {
|
||||
name: string
|
||||
description: string
|
||||
}
|
||||
}
|
||||
|
||||
interface Todos {
|
||||
categories: Categories
|
||||
cards: Card[]
|
||||
columns: Columns
|
||||
groups: Groups
|
||||
}
|
||||
|
||||
const todosFile = 'data/todos.json'
|
||||
|
||||
function setup(data: SubmoduleData): void {
|
||||
const { app /* userDB, url, publicdirs, moduleSpecificData */ } = data
|
||||
|
||||
app.get('/voteTodo', (req: Request, res: any) => {
|
||||
app.get('/voteTodo', (req: Request, res: Response) => {
|
||||
logger.LogReq(req)
|
||||
const userId = req.session.user.id
|
||||
const id: any = req.query.id
|
||||
const todos = utils.ReadJSON(todosFile)
|
||||
const todos: Todos = utils.ReadJSON(todosFile)
|
||||
|
||||
if (!id) {
|
||||
res.json({
|
||||
@@ -47,7 +96,7 @@ function setup(data: SubmoduleData): void {
|
||||
})
|
||||
})
|
||||
|
||||
app.get('/todos', (req: Request, res: any) => {
|
||||
app.get('/todos', (req: Request, res: Response) => {
|
||||
logger.LogReq(req)
|
||||
const userId = req.session.user.id
|
||||
const todos = utils.ReadJSON(todosFile)
|
||||
|
||||
Reference in New Issue
Block a user