mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
add server to monorepo.
This commit is contained in:
41
packages/server/src/api/controllers/Miscellaneous/index.ts
Normal file
41
packages/server/src/api/controllers/Miscellaneous/index.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { Router, Request, Response, NextFunction } from 'express';
|
||||
import BaseController from '@/api/controllers/BaseController';
|
||||
import MiscService from '@/services/Miscellaneous/MiscService';
|
||||
import DateFormatsService from '@/services/Miscellaneous/DateFormats';
|
||||
|
||||
@Service()
|
||||
export default class MiscController extends BaseController {
|
||||
@Inject()
|
||||
dateFormatsService: DateFormatsService;
|
||||
|
||||
/**
|
||||
* Express router.
|
||||
*/
|
||||
router() {
|
||||
const router = Router();
|
||||
|
||||
router.get(
|
||||
'/date_formats',
|
||||
this.validationResult,
|
||||
this.asyncMiddleware(this.dateFormats.bind(this))
|
||||
);
|
||||
return router;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve date formats options.
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {NextFunction} next
|
||||
*/
|
||||
dateFormats(req: Request, res: Response, next: NextFunction) {
|
||||
try {
|
||||
const dateFormats = this.dateFormatsService.getDateFormats();
|
||||
|
||||
return res.status(200).send({ data: dateFormats });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user