diff --git a/consumerWebsite/database/model/apiKeyModel.js b/consumerWebsite/database/model/apiKeyModel.js
index 03bcb95..55e096b 100644
--- a/consumerWebsite/database/model/apiKeyModel.js
+++ b/consumerWebsite/database/model/apiKeyModel.js
@@ -45,7 +45,7 @@ const apikeyModel = sequelize.define(
validate: {
notEmpty: true,
len: [1, 255],
- isIn: [["canRead", "canWrite"]],
+ isIn: [["canRead", "canWrite" , "auto-generated"]],
},
},
createdAt: {
@@ -63,3 +63,46 @@ const apikeyModel = sequelize.define(
);
module.exports = { apikeyModel };
+
+
+/*
+ class AuthToken extends Model {
+ check(){
+ // check expires_on date
+ return this.is_valid;
+ }
+ }
+ AuthToken.init({
+ token:{
+ type: DataTypes.UUID,
+ defaultValue: DataTypes.UUIDV4,
+ allowNull: false,
+ primaryKey: true
+ },
+ expires_on: {
+ type: DataTypes.DATE,
+ allowNull: true,
+ validate:{
+ isDate:true
+ }
+ },
+ username: {
+ type: DataTypes.STRING,
+ ldapModel: 'User',
+ allowNull: false,
+ validate:{
+ notNull: true,
+ },
+ },
+ is_valid: {
+ type: DataTypes.BOOLEAN,
+ defaultValue: true
+ }
+ }, {
+ sequelize,
+ modelName: 'AuthToken',
+ });
+
+
+
+*/
\ No newline at end of file
diff --git a/consumerWebsite/middleware/authChecker.js b/consumerWebsite/middleware/authChecker.js
new file mode 100644
index 0000000..e69de29
diff --git a/consumerWebsite/modules/app.js b/consumerWebsite/modules/app.js
index 680beba..069240b 100644
--- a/consumerWebsite/modules/app.js
+++ b/consumerWebsite/modules/app.js
@@ -1,20 +1,23 @@
const express = require("express");
-const helmet = require("helmet");
const path = require("path");
const app = express();
-const port = 80;
+const port = 3000;
+const ejs = require("ejs");
-const bodyParser = require('body-parser'); // Middleware
+const bodyParser = require("body-parser"); // Middleware
app.use(bodyParser.urlencoded({ extended: false }));
-app.use(helmet());
-//disable x-powered-by header for security reasons
-app.disable("x-powered-by");
+
app.use(express.json());
app.set("json spaces", 2);
-//public folder with path to static files
+// Set up the templating engine to build HTML for the front end.
+app.set("views", path.join(__dirname, "../views"));
+app.set("view engine", "ejs");
+
+// Have express server static content( images, CSS, browser JS) from the public
+// local folder.
app.use(express.static(path.join(__dirname, "../public")));
//middleware logic ( called by next() )
@@ -23,6 +26,9 @@ app.use(express.static(path.join(__dirname, "../public")));
//route logic
app.use("/api/v0", require("../routes/api_routes")); //consumerWebsite\routes\api_routes.js
+//render logic
+app.use("/", require("../routes/render")); //consumerWebsite\routes\render.js
+
// Catch 404 and forward to error handler. If none of the above routes are
// used, this is what will be called.
app.use(function (req, res, next) {
diff --git a/consumerWebsite/public/404.html b/consumerWebsite/public/404.html
deleted file mode 100644
index 63805cf..0000000
--- a/consumerWebsite/public/404.html
+++ /dev/null
@@ -1,174 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
404
- Page Not Found
-
-
-
-
-
-
-
-
-
-
Oops! That page can’t be found.
-
-
-
-
We can’t find the page your are looking for. You can check out our Homepage .
-
Back To Homepage
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/consumerWebsite/public/index.html b/consumerWebsite/public/index.html
deleted file mode 100644
index 5e69868..0000000
--- a/consumerWebsite/public/index.html
+++ /dev/null
@@ -1,260 +0,0 @@
-
-
-
-
-
-
-
-
- EcoSaver
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Welcome to EcoSaver
-
The current airviro system in used by NEA only has 14 substations to record air quality. Our
- project aims to supplement data to NEA and also allow the general consumer to access our IoT sensor
- data through a web service.
-
-
-
-
-
-
Fresh Air
-
A Great day for jogging
-
-
-
-
-
-
Welcome to EcoSaver
-
Hope you enjoy!
-
-
-
-
-
- Previous
-
-
-
- Next
-
-
-
-
-
-
-
-
-
-
-
EcoSaver - Your Air Quality Index Source
-
-
-
-
-
-
-
- Our Approach: Smart and Informative
- We believe in offering precise and comprehensive data to empower your decisions for a better
- quality of life.
-
- Presenting real-time air quality data in a user-friendly format.
- Equipping you with insights into the impact of air quality on health and the environment.
-
- Empowering communities with knowledge to make informed choices for a sustainable future.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/consumerWebsite/public/js/jquery.js b/consumerWebsite/public/js/app.js
similarity index 99%
rename from consumerWebsite/public/js/jquery.js
rename to consumerWebsite/public/js/app.js
index 78db376..3fb3560 100644
--- a/consumerWebsite/public/js/jquery.js
+++ b/consumerWebsite/public/js/app.js
@@ -1,6 +1,6 @@
var app = {};
-/*
+
app.api = (function(app){
var baseURL = '/api/v0/'
@@ -85,7 +85,6 @@ app.api = (function(app){
return {post: post, get: get, put: put, delete: remove}
})(app)
-*/
app.auth = (function(app) {
var user = {}
diff --git a/consumerWebsite/public/js/contact.js b/consumerWebsite/public/js/contact.js
index 7e902c8..98a07a6 100644
--- a/consumerWebsite/public/js/contact.js
+++ b/consumerWebsite/public/js/contact.js
@@ -1,11 +1,11 @@
-const newAccessKey = '7f7ce777-6a56-4e5e-bfac-3b83c6453e65';
-//const newAccessKey = process.env.ACCESS_KEY;
+require('dotenv').config({ path: path.resolve(__dirname, '../../../.env') })
+
document.addEventListener('DOMContentLoaded', () => {
const form = document.getElementById('form');
// Set the new value for the access_key input field
- form.querySelector('input[name="access_key"]').value = newAccessKey;
+ form.querySelector('input[name="access_key"]').value = process.env.emailKey;
form.addEventListener('submit', async (event) => {
event.preventDefault(); // Prevent default form submission
@@ -41,3 +41,4 @@ document.addEventListener('DOMContentLoaded', () => {
}
});
});
+
diff --git a/consumerWebsite/public/news.html b/consumerWebsite/public/news.html
deleted file mode 100644
index 23d79c8..0000000
--- a/consumerWebsite/public/news.html
+++ /dev/null
@@ -1,247 +0,0 @@
-
-
-
-
-
-
-
-
- N & LW Lawn Care - Landscaping Bootstrap4 HTML5 Responsive Template
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Singapore's air quality hits unhealthy range, 'slightly hazy' conditions
- forecast for Saturday
-
he National Environment Agency said there has been a "significant increase"
- in the number of hotspots in Sumatra.
-
Read More →
-
-
-
-
-
-
-
-
Singapore Government Agencies Stand Ready To Mitigate Impact Of Haze
-
As of 29 September 2023, 3pm, the 24-hr Pollutant Standards Index (PSI) is
- 81 (Moderate range) in the East region of Singapore. Accordingly, the 28 public agencies
- that make up the Government’s Haze Task Force (HTF), are ready to roll out their respective
- haze action plans should the air quality deteriorate into the Unhealthy range (24-hour PSI
- above 100).
-
Read More →
-
-
-
-
-
-
-
-
High risk of severe transboundary haze in 2023, public advised to be
- prepared: Singapore institute
-
A latest report predicts a high risk of severe haze occurring in Southeast
- Asia, though not as severe as in 2015
-
Read More →
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/consumerWebsite/routes/render.js b/consumerWebsite/routes/render.js
new file mode 100644
index 0000000..356c63b
--- /dev/null
+++ b/consumerWebsite/routes/render.js
@@ -0,0 +1,60 @@
+/*
+'use strict';
+
+var router = require('express').Router();
+const conf = require('../conf')
+
+const values ={
+ title: conf.environment !== 'production' ? ` ` : ''
+}
+
+router.get('/', async function(req, res, next) {
+ res.render('runner', {...values});
+});
+
+
+router.get('/topics', function(req, res, next) {
+ res.render('topics', {...values});
+});
+
+router.get('/chat', function(req, res, next) {
+ res.render('chat', {...values});
+});
+
+router.get('/login*', function(req, res, next) {
+ res.render('login', {redirect: req.query.redirect, ...values});
+});
+
+router.get('/runner', function(req, res, next) {
+ res.render('runner', {...values});
+});
+
+router.get('/worker', function(req, res, next) {
+ res.render('worker', {...values});
+});
+
+module.exports = router;
+
+*/
+
+'use strict';
+
+var router = require('express').Router();
+
+//landing page of index
+router.get('/', function(req, res, next) {
+ res.render('index');
+});
+
+//news page
+router.get('/news', function(req, res, next) {
+ res.render('news');
+});
+
+//404 page
+router.get('*', function(req, res, next) {
+ res.render('404');
+});
+
+
+module.exports = router;
diff --git a/consumerWebsite/views/404.ejs b/consumerWebsite/views/404.ejs
new file mode 100644
index 0000000..ccb157b
--- /dev/null
+++ b/consumerWebsite/views/404.ejs
@@ -0,0 +1,37 @@
+<%- include('top') %>
+
+
+
+
+
+
404
+ Page Not Found
+
+
+
+
+
+
+
+
+
+
Oops! That page can’t be found.
+
+
+
+
We can’t find the page your are looking for. You can check out our Homepage .
+
Back To Homepage
+
+
+
+
+
+
+<%- include('bot') %>
\ No newline at end of file
diff --git a/consumerWebsite/views/bot.ejs b/consumerWebsite/views/bot.ejs
new file mode 100644
index 0000000..898fd63
--- /dev/null
+++ b/consumerWebsite/views/bot.ejs
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+