mirror of
https://github.com/crystelf/crystelf-core.git
synced 2025-10-14 05:19:19 +00:00
32 lines
761 B
TypeScript
32 lines
761 B
TypeScript
import express from 'express';
|
|
import TestService from './test.service';
|
|
import response from '../../core/utils/system/response';
|
|
import logger from '../../core/utils/system/logger';
|
|
|
|
class TestController {
|
|
private readonly router: express.Router;
|
|
|
|
constructor() {
|
|
this.router = express.Router();
|
|
this.initRouter();
|
|
}
|
|
|
|
public getRouter(): express.Router {
|
|
return this.router;
|
|
}
|
|
|
|
public initRouter(): void {
|
|
this.router.get('/test', this.test);
|
|
}
|
|
private test = async (req: express.Request, res: express.Response): Promise<void> => {
|
|
try {
|
|
const result = await TestService.test();
|
|
await response.success(res, result);
|
|
} catch (err) {
|
|
logger.error(err);
|
|
}
|
|
};
|
|
}
|
|
|
|
export default new TestController();
|