Skip to content

Commit

Permalink
added get API endpoint for pacific power exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
s-egge committed Apr 5, 2024
1 parent c729b0d commit f78d950
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 30 deletions.
8 changes: 8 additions & 0 deletions backend/app/pacific_power_exclusion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Response = require('/opt/nodejs/response.js')
const PacificPowerExclusion = require('/opt/nodejs/models/pacific_power_exclusion.js')

exports.get = async (event, context) => {
let response = new Response(event)
response.body = JSON.stringify(await new PacificPowerExclusion().get())
return response
}
10 changes: 10 additions & 0 deletions backend/dependencies/nodejs/models/pacific_power_exclusion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const DB = require('/opt/nodejs/sql-access.js')

class PacificPowerExclusion {
async get() {
await DB.connect()
return DB.query(`SELECT * FROM pacific_power_exclusion`)
}
}

module.exports = PacificPowerExclusion
75 changes: 45 additions & 30 deletions backend/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Globals:
# enable CORS; to make more specific, change the origin wildcard
# to a particular domain name, e.g. "'www.example.com'"
Cors:
AllowMethods: "'POST, GET'"
AllowHeaders: "'X-Forwarded-For'"
AllowOrigin: "'oregonstate.edu'"
MaxAge: "'600'"
AllowCredentials: True
AllowMethods: "'POST, GET'"
AllowHeaders: "'X-Forwarded-For'"
AllowOrigin: "'oregonstate.edu'"
MaxAge: "'600'"
AllowCredentials: True
BinaryMediaTypes:
- image~1gif
- image~1png
Expand All @@ -26,20 +26,20 @@ Globals:
- multipart/form-data
HttpApi:
CorsConfiguration:
AllowMethods:
- GET
- POST
AllowHeaders:
- "'X-Forwarded-For'"
AllowOrigins:
- "https://dashboard.sustainability.oregonstate.edu"
MaxAge: 600
AllowCredentials: True
AllowMethods:
- GET
- POST
AllowHeaders:
- "'X-Forwarded-For'"
AllowOrigins:
- 'https://dashboard.sustainability.oregonstate.edu'
MaxAge: 600
AllowCredentials: True
Parameters:
LambdaCommonLayer:
Type: String
Default: arn:aws:lambda:us-west-2:005937143026:layer:LambdaCommonLayer:97

Resources:
test:
Type: AWS::Serverless::Function
Expand Down Expand Up @@ -238,7 +238,7 @@ Resources:
Properties:
Timeout: 30
MemorySize: 256
CodeUri: app/
CodeUri: app/
Handler: meter.batchData
Layers:
- !Ref LambdaCommonLayer
Expand Down Expand Up @@ -718,18 +718,33 @@ Resources:
Properties:
Path: /admin/devices
Method: get
ppExclude:
Type: AWS::Serverless::Function
Properties:
MemorySize: 128
CodeUri: app/
Handler: pacific_power_exclusion.get
Layers:
- !Ref LambdaCommonLayer
- !Ref EnergyModelLayer
Events:
Building:
Type: Api
Properties:
Path: /ppexclude
Method: get
EnergyModelLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: EnergyModelLayer
Description: DB Model Defs
ContentUri: dependencies/
CompatibleRuntimes:
- nodejs6.10
- nodejs8.10
- nodejs10.x
- nodejs12.x
- nodejs16.x
- nodejs18.x
LicenseInfo: 'MIT'
RetentionPolicy: Retain
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: EnergyModelLayer
Description: DB Model Defs
ContentUri: dependencies/
CompatibleRuntimes:
- nodejs6.10
- nodejs8.10
- nodejs10.x
- nodejs12.x
- nodejs16.x
- nodejs18.x
LicenseInfo: 'MIT'
RetentionPolicy: Retain

0 comments on commit f78d950

Please sign in to comment.