Merge branch 'main' into edison_dev2
This commit is contained in:
+16
-16
@@ -18,9 +18,9 @@ async function startServer() {
|
|||||||
|
|
||||||
const db = mysql.createPool({
|
const db = mysql.createPool({
|
||||||
host: process.env.DB_HOST,
|
host: process.env.DB_HOST,
|
||||||
user: process.env.DB_USERNAME,
|
user: process.env.DB_USER,
|
||||||
password: process.env.DB_PASSWORD,
|
password: process.env.DB_PASSWORD,
|
||||||
database: process.env.DB_DATABASE,
|
database: process.env.DB_NAME,
|
||||||
port: process.env.DB_PORT,
|
port: process.env.DB_PORT,
|
||||||
waitForConnections: true,
|
waitForConnections: true,
|
||||||
connectionLimit: 10,
|
connectionLimit: 10,
|
||||||
@@ -59,22 +59,22 @@ async function startServer() {
|
|||||||
|
|
||||||
app.use(cors(corsOptions));
|
app.use(cors(corsOptions));
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
// --- Public server time endpoints (no auth, no cache) ---
|
// --- Public server time endpoints (no auth, no cache) ---
|
||||||
const timeHandler = (req, res) => {
|
const timeHandler = (req, res) => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const ymdKL = new Intl.DateTimeFormat('en-CA', {
|
const ymdKL = new Intl.DateTimeFormat('en-CA', {
|
||||||
timeZone: 'Asia/Kuala_Lumpur',
|
timeZone: 'Asia/Kuala_Lumpur',
|
||||||
year: 'numeric', month: '2-digit', day: '2-digit'
|
year: 'numeric', month: '2-digit', day: '2-digit'
|
||||||
}).format(now); // "YYYY-MM-DD"
|
}).format(now); // "YYYY-MM-DD"
|
||||||
|
|
||||||
res.set('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
|
res.set('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
|
||||||
res.set('Pragma', 'no-cache');
|
res.set('Pragma', 'no-cache');
|
||||||
res.set('Expires', '0');
|
res.set('Expires', '0');
|
||||||
|
|
||||||
res.json({ nowIso: now.toISOString(), tz: 'Asia/Kuala_Lumpur', ymdKL });
|
res.json({ nowIso: now.toISOString(), tz: 'Asia/Kuala_Lumpur', ymdKL });
|
||||||
};
|
};
|
||||||
app.get('/time', timeHandler); // public path
|
app.get('/time', timeHandler); // public path
|
||||||
app.get('/api/time', timeHandler); // also under /api
|
app.get('/api/time', timeHandler); // also under /api
|
||||||
|
|
||||||
app.use('/api/managers', managerRoutes(db));
|
app.use('/api/managers', managerRoutes(db));
|
||||||
app.use('/api', workerRoutes(db));
|
app.use('/api', workerRoutes(db));
|
||||||
|
|||||||
Reference in New Issue
Block a user