Skip to content

Commit

Permalink
Working demo
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSloanRanger committed Feb 2, 2024
1 parent 51b71ed commit 797cf1a
Show file tree
Hide file tree
Showing 9 changed files with 1,533 additions and 619 deletions.
17 changes: 17 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file specifies files that are *not* uploaded to Google Cloud
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

# Node.js dependencies:
node_modules/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/.vs/ncr-agile-wombo/v17/.wsuo
/.vs/slnx.sqlite
/.vs/VSWorkspaceState.json
node_modules
39 changes: 12 additions & 27 deletions api/atmRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,15 @@ router.post("/api/atms/filter", async (req, res) => {
const atms = await db
.collection("ATMs")
.find({
Accessibility: {
$all: req.body.Accessibility
? req.body.Accessibility
: ["AudioCashMachine", "WheelchairAccess"],
Accessibility: req.body.Accessibility
? { $all: req.body.Accessibility }
: { $exists: true, $ne: null },
ATMServices: req.body.ATMServices
? { $all: req.body.ATMServices }
: { $exists: true, $ne: null },
Access24HoursIndicator: {
$in: [req.body.Access24HoursIndicator, true, false],
},
ATMServices: {
$all: req.body.ATMServices,
},
ATMServices: {
$all: req.body.ATMServices
? req.body.ATMServices
: [
"CashWithdrawal",
"CashDeposits",
"PINChange",
"ChequeDeposits",
"Balance",
],
},
Access24HoursIndicator: req.body.Access24HoursIndicator
? req.body.Access24HoursIndicator
: {
$in: [true, false],
},
$and: [
{
$expr: {
Expand All @@ -65,12 +50,12 @@ router.post("/api/atms/filter", async (req, res) => {
},
{
$expr: {
$lt: [
req.body.Latitude - req.body.Radius / 111,
$gt: [
{
$toDouble:
"$Location.PostalAddress.GeoLocation.GeographicCoordinates.Latitude",
},
req.body.Latitude - req.body.Radius / 111,
],
},
},
Expand All @@ -87,12 +72,12 @@ router.post("/api/atms/filter", async (req, res) => {
},
{
$expr: {
$lt: [
req.body.Longitude - req.body.Radius / 111,
$gt: [
{
$toDouble:
"$Location.PostalAddress.GeoLocation.GeographicCoordinates.Longitude",
},
req.body.Longitude - req.body.Radius / 111,
],
},
},
Expand Down
26 changes: 8 additions & 18 deletions api/branchRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,15 @@ router.get("/api/branches", async (req, res) => {

router.post("/api/branches/filter", async (req, res) => {
try {
const atms = await db
const branches = await db
.collection("Branches")
.find({
Accessibility: {
$all: req.body.Accessibility
? req.body.Accessibility
: [
"WheelchairAccess",
"LowerLevelCounter",
"LevelAccess",
"InductionLoop",
"AutomaticDoors",
],
},
ServiceAndFacility: {
$all: req.body.ServiceAndFacility
? req.body.ServiceAndFacility
: ["WiFi"],
},
Accessibility: req.body.Accessibility
? { $all: req.body.Accessibility }
: { $exists: true, $ne: null },
ServiceAndFacility: req.body.ServiceAndFacility
? { $all: req.body.ServiceAndFacility }
: { $exists: true, $ne: null },
$and: [
{
$expr: {
Expand Down Expand Up @@ -91,7 +81,7 @@ router.post("/api/branches/filter", async (req, res) => {
],
})
.toArray();
res.json(atms);
res.json(branches);
} catch (error) {
handleError(res, error);
}
Expand Down
20 changes: 20 additions & 0 deletions backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
runtime: nodejs20

service: backend

instance_class: F1

automatic_scaling:
min_instances: 0
max_instances: 1
min_idle_instances: 0
max_idle_instances: 1
min_pending_latency: 30ms
max_pending_latency: automatic
max_concurrent_requests: 50

handlers:
- url: /.*
secure: always
redirect_http_response_code: 301
script: auto
2 changes: 2 additions & 0 deletions be/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ const express = require("express");
const cors = require("cors");
const routes = require("./routes");
const bodyParser = require("body-parser");
const path = require("path");

const app = express();
app.use(cors());
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, "..", "fe")));

// Use the routes defined in routes.js
app.use("/", routes);
Expand Down
Loading

0 comments on commit 797cf1a

Please sign in to comment.