UP controller -> ts
This commit is contained in:
parent
b4b18cd44d
commit
905ab263de
@ -1,9 +1,11 @@
|
|||||||
var cashTransactionModel = require('../models/cashTransactionModel.js');
|
import { type Request, type Response } from "express";
|
||||||
|
import cashTransactionModel from '../models/cashTransactionModel.js';
|
||||||
|
|
||||||
const types = ['ZAVRNITEV POS NAKUP', 'POS NAKUP', 'BA DVIG', 'priliv', 'SDD', 'SPLET/TEL NAKUP', 'PREDAVTORIZACIJE'];
|
const types = ['ZAVRNITEV POS NAKUP', 'POS NAKUP', 'BA DVIG', 'priliv', 'SDD', 'SPLET/TEL NAKUP', 'PREDAVTORIZACIJE'];
|
||||||
module.exports = {
|
|
||||||
|
|
||||||
list: async function (req, res) {
|
export default {
|
||||||
|
|
||||||
|
list: async function (req: Request, res: Response) {
|
||||||
try {
|
try {
|
||||||
var transactions;
|
var transactions;
|
||||||
const date = req.body.date;
|
const date = req.body.date;
|
||||||
@ -30,7 +32,7 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
create: async function (req, res) {
|
create: async function (req: Request, res: Response) {
|
||||||
const rawString = req.body.messageBody;
|
const rawString = req.body.messageBody;
|
||||||
|
|
||||||
if (rawString == "") return res.status(400).json({ message: "empty string" });
|
if (rawString == "") return res.status(400).json({ message: "empty string" });
|
||||||
@ -83,7 +85,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
delete: async function (req, res) {
|
delete: async function (req: Request, res: Response) {
|
||||||
cashTransactionModel.deleteMany({ type: -1 })
|
cashTransactionModel.deleteMany({ type: -1 })
|
||||||
.then(data => {
|
.then(data => {
|
||||||
res.status(201).json({ message: "OK" });
|
res.status(201).json({ message: "OK" });
|
@ -1,9 +1,9 @@
|
|||||||
var { GameModel } = require('../models/mediaModel');
|
import { type Request, type Response } from "express";
|
||||||
|
import { GameModel } from '../models/mediaModel';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
|
||||||
module.exports = {
|
list: function (req: Request, res: Response) {
|
||||||
|
|
||||||
list: function (req, res) {
|
|
||||||
GameModel.find({}, { __v: 0 })
|
GameModel.find({}, { __v: 0 })
|
||||||
.then(games => {
|
.then(games => {
|
||||||
return res.json(games);
|
return res.json(games);
|
||||||
@ -16,7 +16,7 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
create: async function (req, res) {
|
create: async function (req: Request, res: Response) {
|
||||||
var gameCode = req.body.code;
|
var gameCode = req.body.code;
|
||||||
const userFound = req.user;
|
const userFound = req.user;
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var date = new Date(gameData[0].first_release_date * 1000);
|
var date = new Date(gameData[0].first_release_date * 1000);
|
||||||
const options = { day: 'numeric', month: 'short', year: 'numeric' }
|
const options: Intl.DateTimeFormatOptions = { day: 'numeric', month: 'short', year: 'numeric' }
|
||||||
var dateStr = date.toLocaleDateString(undefined, options);
|
var dateStr = date.toLocaleDateString(undefined, options);
|
||||||
|
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
remove: async function (req, res) {
|
remove: async function (req: Request, res: Response) {
|
||||||
var id = req.body.code;
|
var id = req.body.code;
|
||||||
|
|
||||||
try {
|
try {
|
@ -1,16 +1,17 @@
|
|||||||
var { MovieModel, SeriesModel } = require('../models/mediaModel');
|
import { type Request, type Response } from "express";
|
||||||
|
import { MovieModel, SeriesModel } from '../models/mediaModel';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mediaController.js
|
* mediaController.js
|
||||||
*
|
*
|
||||||
* @description :: Server-side logic for managing movies and series.
|
* @description :: Server-side logic for managing movies and series.
|
||||||
*/
|
*/
|
||||||
module.exports = {
|
export default {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mediaController.list()
|
* mediaController.list()
|
||||||
*/
|
*/
|
||||||
list: function (req, res) {
|
list: function (req: Request, res: Response) {
|
||||||
const MediaModel = req.baseUrl.includes('movies') ? MovieModel : SeriesModel;
|
const MediaModel = req.baseUrl.includes('movies') ? MovieModel : SeriesModel;
|
||||||
|
|
||||||
MediaModel.find({}, { __v: 0 })
|
MediaModel.find({}, { __v: 0 })
|
||||||
@ -28,7 +29,7 @@ module.exports = {
|
|||||||
/**
|
/**
|
||||||
* mediaController.create()
|
* mediaController.create()
|
||||||
*/
|
*/
|
||||||
create: async function (req, res) {
|
create: async function (req: Request, res: Response) {
|
||||||
const mediaCode = req.body.code;
|
const mediaCode = req.body.code;
|
||||||
const userFound = req.user;
|
const userFound = req.user;
|
||||||
try {
|
try {
|
||||||
@ -63,7 +64,7 @@ module.exports = {
|
|||||||
/**
|
/**
|
||||||
* mediaController.delete()
|
* mediaController.delete()
|
||||||
*/
|
*/
|
||||||
remove: async function (req, res) {
|
remove: async function (req: Request, res: Response) {
|
||||||
var id = req.body.code;
|
var id = req.body.code;
|
||||||
|
|
||||||
try {
|
try {
|
@ -1,6 +1,6 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
import cashTransaction from '../../controllers/cashTransactionController.js';
|
import cashTransaction from '../../controllers/cashTransactionController';
|
||||||
|
|
||||||
router.post('/list', cashTransaction.list);
|
router.post('/list', cashTransaction.list);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
var router = express.Router();
|
var router = express.Router();
|
||||||
import gameController from '../../controllers/gameController.js';
|
import gameController from '../../controllers/gameController';
|
||||||
import checkAuthenticated from '../../miscellaneous/checkAuthenticated';
|
import checkAuthenticated from '../../miscellaneous/checkAuthenticated';
|
||||||
|
|
||||||
router.get('/', gameController.list);
|
router.get('/', gameController.list);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user