Spaces:
Sleeping
Sleeping
anoderb
feat: implement chatbot service, active shift logic corrections, audit logs, and void transaction tool
48013ee | import express, { Application, Request, Response } from 'express'; | |
| import cors from 'cors'; | |
| import path from 'path'; | |
| import fs from 'fs'; | |
| import router from './routes'; | |
| import { errorHandler } from './middlewares/error.middleware'; | |
| // Pastikan direktori export ada | |
| const exportsDir = path.join(__dirname, '../public/exports'); | |
| if (!fs.existsSync(exportsDir)) { | |
| fs.mkdirSync(exportsDir, { recursive: true }); | |
| } | |
| const app: Application = express(); | |
| // Global Middleware | |
| app.use(cors()); | |
| app.use(express.json({ limit: '50mb' })); // Allow larger payloads (useful for base64 images) | |
| app.use(express.urlencoded({ extended: true, limit: '50mb' })); | |
| app.use('/exports', express.static(path.join(__dirname, '../public/exports'))); | |
| // Routing API | |
| app.use('/api', router); | |
| // Default Route | |
| app.get('/', (req: Request, res: Response) => { | |
| res.json({ message: 'Welcome to Tokiva POS Node.js API Server' }); | |
| }); | |
| // Global Error Handler | |
| app.use(errorHandler); | |
| export default app; | |