diff --git a/public/index.ejs b/public/index.ejs index 1eafa49..7cf568a 100644 --- a/public/index.ejs +++ b/public/index.ejs @@ -52,6 +52,9 @@ + @@ -70,7 +73,11 @@

Find AED Locations in Penang

Quick access to life-saving Automated External Defibrillators (AED) locations across Penang. Every second counts in an emergency.

- + + + + +
AED Location Map diff --git a/public/pages/aed.ejs b/public/pages/aed.ejs new file mode 100644 index 0000000..6815aa4 --- /dev/null +++ b/public/pages/aed.ejs @@ -0,0 +1,72 @@ + + + + + + <%= title %> - AED Locations + + + + + +
+

AED Locations in Penang

+
+
+ + + + + + diff --git a/public/pages/how-to-use-aed.ejs b/public/pages/how-to-use-aed.ejs new file mode 100644 index 0000000..5987dae --- /dev/null +++ b/public/pages/how-to-use-aed.ejs @@ -0,0 +1,136 @@ + + + + + + <%= title %> - How to Use an AED + + + + + + + + + + +
+
+
+
+

How to Use an AED

+

A Step-by-Step Guide for Emergency Situations

+
+
+
+
+ + +
+
+
+
+ +
+
Step 1: Call Emergency Services
+

Before using the AED, ensure someone has called emergency services or do it yourself if you are alone.

+
+ + +
+
Step 2: Check the Scene
+

Ensure the environment is safe for both you and the victim. Make sure the area is free of hazards (e.g., water, traffic).

+
+ + +
+
Step 3: Check the Victim
+
    +
  • Assess the victim's responsiveness by tapping them and shouting, "Are you okay?"
  • +
  • If the victim is unresponsive and not breathing or only gasping, proceed to the next steps.
  • +
+
+ + + + +
+

Important Tips

+
    +
  • Do not use the AED in water or while the victim is in water.
  • +
  • Make sure the pads do not touch each other.
  • +
  • If there are signs of life, place the victim in the recovery position and monitor them.
  • +
+
+ + +
+

Training

+

While AEDs are designed for public use, taking a CPR and AED training course can greatly enhance your confidence and effectiveness in an emergency situation. Organizations such as the American Heart Association or Red Cross offer classes that teach these skills.

+
+
+
+
+
+ + + + + + + diff --git a/src/app.ts b/src/app.ts index 6a7194c..5495e3b 100644 --- a/src/app.ts +++ b/src/app.ts @@ -4,6 +4,9 @@ import cors from 'cors'; import aed from './routes/aed'; import helmet from 'helmet'; import * as path from 'path'; +import { GetAED } from './controllers/get_data'; +import { AED } from './models/aed_model'; + /** * @description 主应用程序实例配置文件 @@ -22,6 +25,40 @@ app.use(bodyParser.json()); // 解析 JSON 格 app.disable('x-powered-by'); // 移除 X-Powered-By 标头,提高安全性 app.use(cors()); // 允许跨域请求,支持前后端分离 app.use(helmet()); // 添加安全相关的 HTTP 头,增强应用安全性 +app.use( + helmet({ + contentSecurityPolicy: { + directives: { + defaultSrc: ["'self'"], + scriptSrc: [ + "'self'", + "'unsafe-inline'", + "'unsafe-eval'", + "cdn.jsdelivr.net", + "unpkg.com", + "*.bootstrap.com", + ], + styleSrc: [ + "'self'", + "'unsafe-inline'", + "cdn.jsdelivr.net", + "*.bootstrap.com", + "cdnjs.cloudflare.com", + "*.bootstrapcdn.com", + ], + imgSrc: ["'self'", "data:", "https:", "blob:"], + connectSrc: ["'self'", "https:"], + fontSrc: ["'self'", "https:", "data:", "cdnjs.cloudflare.com"], + objectSrc: ["'none'"], + mediaSrc: ["'self'"], + frameSrc: ["'self'"], + tileSrc: ["'self'", "https://*.tile.openstreetmap.org"], + }, + }, + crossOriginEmbedderPolicy: false, + crossOriginResourcePolicy: false, + }) +); /** * 配置应用程序路由 @@ -58,6 +95,19 @@ app.get('/public/main', (req, res) => { res.render('index', { title: APP_NAME }); }); +app.get('/public/locate-aed', (req, res) => { + const aedData = GetAED(); + + res.render('pages/aed', { + title: APP_NAME, + aedData: aedData || [] + }); +}); + +app.get('/public/how-to-use-aed', (req, res) => { + res.render('pages/how-to-use-aed', { title: APP_NAME }); +}); + app.get('/public/pages/contact', (req, res) => { res.render('pages/contact', { title: APP_NAME }); }); diff --git a/src/index.ts b/src/index.ts index 7da86dd..a12a4f9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,5 +18,5 @@ if (PORT === "443") } app.listen(PORT, () => { - console.log(`AED Server is running on http://localhost:${PORT}`); + console.log(`AED 服务器正在运行,访问地址: http://localhost:${PORT}`); }); diff --git a/src/routes/aed.ts b/src/routes/aed.ts index c304165..a1b6481 100644 --- a/src/routes/aed.ts +++ b/src/routes/aed.ts @@ -16,8 +16,15 @@ const aed = Router(); aed.get('/all', (req, res) => { const data = GetAED(); - console.info(`GET::[/aed/all]`); // 记录请求日志 - res.send(data); // 发送响应数据 + if (data) + { + console.info(`GET::[/aed/all]`); // 记录请求日志 + res.send(data); // 发送响应数据 + } + else + { + res.status(404).json({ error: 'No AED data found' }); + } }); export default aed;