feat: add global functions like versions

master
ogomez-at-wiris 2022-02-27 12:06:03 +01:00
parent 434a54b038
commit ca989d7a23
3 changed files with 24 additions and 1 deletions

14
src/global_service.ts Normal file
View File

@ -0,0 +1,14 @@
import { Request, Response, NextFunction, response } from "express";
export default class GlobalService {
public static getVersions = async (
req: Request,
res: Response,
next: NextFunction
) => {
return res.status(200).json({
beat: '2022.02.27',
});
};
}

8
src/routes/global.ts Normal file
View File

@ -0,0 +1,8 @@
import express from "express";
import PackAPI from "../pack_api";
import PackUploader from "../pack_upload";
import GlobalService from "../global_service";
export const globalRoutes = express.Router();
globalRoutes.get("/versions", GlobalService.getVersions);

View File

@ -3,6 +3,7 @@ import express, { Express } from "express";
import morgan from "morgan";
import os from "os";
import { packRoutes } from "./routes/packs";
import { globalRoutes } from "./routes/global";
import PackAPI from "./pack_api";
import PackService from "./services/pack_service";
@ -48,7 +49,7 @@ router.use((req, res, next) => {
/** Routes */
router.use("/", packRoutes);
router.use("/", globalRoutes);
/** Error handling */
router.use((req, res, next) => {
const error = new Error("not found");