Spaces:
Paused
Paused
Download server.js from ismizo/tenderizer: direct link, hf CLI and curl.
- Browser
- Download file 1.74 kB
-
https://huggingface.co/spaces/ismizo/tenderizer/resolve/main/server.js
- Command line
-
hf download hf://spaces/ismizo/tenderizer/server.js
-
curl -L -o server.js https://huggingface.co/spaces/ismizo/tenderizer/resolve/main/server.js
1.74 kB
| import express from 'express'; | |
| import dotenv from 'dotenv'; | |
| import cors from 'cors'; | |
| import helmet from 'helmet'; | |
| import morgan from 'morgan'; | |
| import path from 'path'; | |
| import { fileURLToPath } from 'url'; | |
| // Configs | |
| import connectDB from './src/config/db.js'; | |
| import r2Client from './src/config/storage.js'; | |
| import authRoutes from './src/routes/authRoutes.js'; | |
| import tenderRoutes from './src/routes/tenderRoutes.js'; | |
| import paymentRoutes from './src/routes/paymentRoutes.js'; | |
| import adminRoutes from './src/routes/adminRoutes.js'; | |
| // Load env vars | |
| dotenv.config(); | |
| // Connect to Database | |
| connectDB(); | |
| const app = express(); | |
| app.set('trust proxy', 1); | |
| // Middleware | |
| app.use(express.json()); | |
| app.use(cors()); | |
| app.use(helmet({ | |
| contentSecurityPolicy: false, | |
| })); | |
| app.use(morgan('dev')); | |
| // Static Files (Frontend) | |
| const __filename = fileURLToPath(import.meta.url); | |
| const __dirname = path.dirname(__filename); | |
| app.use(express.static(path.join(__dirname, 'public'))); | |
| // Routes | |
| app.use('/api/auth', authRoutes); | |
| app.use('/api/tenders', tenderRoutes); | |
| app.use('/api/payments', paymentRoutes); | |
| app.use('/api/admin', adminRoutes); | |
| // Health Check | |
| app.get('/api/health', (req, res) => { | |
| res.json({ | |
| status: 'ok', | |
| message: 'The Tenderizer API is running', | |
| timestamp: new Date() | |
| }); | |
| }); | |
| // Serve Frontend for root | |
| app.get('/', (req, res) => { | |
| res.sendFile(path.join(__dirname, 'public', 'index.html')); | |
| }); | |
| // Catch admin page | |
| app.get('/admin', (req, res) => { | |
| res.sendFile(path.join(__dirname, 'public', 'admin.html')); | |
| }); | |
| // Start Server | |
| const PORT = process.env.PORT || 3000; | |
| app.listen(PORT, () => { | |
| console.log(`Server running in ${process.env.NODE_ENV} mode on port ${PORT}`); | |
| }); | |