Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
9fc1aae5b5 | |||
9bcf0a8b12 | |||
690c50754b | |||
d205bd3a37 | |||
bfcce67788 |
@ -1,4 +1,3 @@
|
||||
NODE_ENV=production
|
||||
VUE_APP_PM_API_BASE=https://pmapi-dev.jdb-labs.com/v0
|
||||
VUE_APP_LOG_LEVEL=INFO
|
||||
VUE_APP_LOG_LEVEL=TRACE
|
||||
VUE_APP_API_LOG_LEVEL=ERROR
|
3
.env.prod
Normal file
3
.env.prod
Normal file
@ -0,0 +1,3 @@
|
||||
VUE_APP_PM_API_BASE=https://pmapi.jdb-labs.com/v0
|
||||
VUE_APP_LOG_LEVEL=INFO
|
||||
VUE_APP_API_LOG_LEVEL=ERROR
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -26,9 +26,3 @@ yarn-error.log*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
# Terrform files
|
||||
.terraform/
|
||||
|
||||
# API Testing Files
|
||||
api/temp/
|
||||
|
14
Makefile
14
Makefile
@ -1,13 +1,8 @@
|
||||
VERSION:=$(shell git describe --always)
|
||||
TARGET_ENV ?= dev
|
||||
TARGET_ENV?=dev
|
||||
|
||||
build: dist/personal-measure-api.tar.gz dist/personal-measure-web.tar.gz
|
||||
|
||||
clean:
|
||||
-rm -r dist
|
||||
-rm api/personal_measure_api
|
||||
-rm -r web/dist
|
||||
|
||||
dist/personal-measure-api.tar.gz:
|
||||
-mkdir dist
|
||||
make -C api personal_measure_api
|
||||
@ -16,7 +11,7 @@ dist/personal-measure-api.tar.gz:
|
||||
|
||||
dist/personal-measure-web.tar.gz:
|
||||
-mkdir dist
|
||||
TARGET_ENV=$(TARGET_ENV) make -C web build
|
||||
(TARGET_ENV=$(TARGET_ENV) ./set-env.sh make -C web build)
|
||||
tar czf dist/personal-measure-web-${VERSION}.tar.gz -C web/dist .
|
||||
cp dist/personal-measure-web-${VERSION}.tar.gz dist/personal-measure-web.tar.gz
|
||||
|
||||
@ -36,3 +31,8 @@ deploy-web: dist/personal-measure-web.tar.gz
|
||||
rm -r temp-deploy
|
||||
|
||||
deploy: deploy-api deploy-web
|
||||
|
||||
clean:
|
||||
-rm -r dist
|
||||
-rm api/personal_measure_api
|
||||
-rm -r web/dist
|
||||
|
@ -14,8 +14,7 @@ skipExt = @["nim"]
|
||||
# Dependencies
|
||||
|
||||
requires @["nim >= 0.19.4", "bcrypt", "docopt >= 0.6.8", "isaac >= 0.1.3",
|
||||
"jester >= 0.4.3", "jwt", "tempfile", "uuids >= 0.1.10" ]
|
||||
"jester >= 0.4.1", "jwt", "tempfile", "uuids >= 0.1.10" ]
|
||||
|
||||
requires "https://git.jdb-labs.com/jdb/nim-cli-utils.git >= 0.6.3"
|
||||
requires "https://git.jdb-labs.com/jdb/nim-time-utils.git >= 0.5.0"
|
||||
requires "https://git.jdb-labs.com/jdb-labs/fiber-orm-nim.git >= 0.2.0"
|
||||
|
@ -47,7 +47,7 @@ proc loadConfig*(args: Table[string, docopt.Value] = initTable[string, docopt.Va
|
||||
port: parseInt(cfg.getVal("port", "8080")),
|
||||
pwdCost: cast[int8](parseInt(cfg.getVal("pwd-cost", "11"))),
|
||||
knownOrigins: toSeq(knownOriginsArray).mapIt(it.getStr))
|
||||
|
||||
|
||||
proc initContext(args: Table[string, docopt.Value]): PMApiContext =
|
||||
|
||||
var cfg: PMApiConfig
|
||||
|
@ -20,7 +20,7 @@ proc newSession*(user: User): Session =
|
||||
|
||||
template halt(code: HttpCode,
|
||||
headers: RawHeaders,
|
||||
content: string) =
|
||||
content: string): typed =
|
||||
## Immediately replies with the specified request. This means any further
|
||||
## code will not be executed after calling this template in the current
|
||||
## route.
|
||||
@ -69,6 +69,11 @@ template statusResp(code: HttpCode, details: string = "", headersToSend: RawHead
|
||||
}),
|
||||
headersToSend)
|
||||
|
||||
template execptionResp(ex: ref Exception, details: string = ""): void =
|
||||
when not defined(release): debug ex.getStackTrace()
|
||||
error details & ":\n" & ex.msg
|
||||
statusResp(Http500)
|
||||
|
||||
# internal JSON parsing utils
|
||||
proc getIfExists(n: JsonNode, key: string): JsonNode =
|
||||
## convenience method to get a key from a JObject or return null
|
||||
|
@ -1,8 +1,10 @@
|
||||
import db_postgres, fiber_orm, uuids
|
||||
import db_postgres, macros, options, postgres, sequtils, strutils,
|
||||
times, timeutils, unicode, uuids
|
||||
|
||||
import ./models
|
||||
import ./db_common
|
||||
|
||||
export fiber_orm.NotFoundError
|
||||
export db_common.NotFoundError
|
||||
|
||||
type
|
||||
PMApiDb* = ref object
|
||||
@ -12,24 +14,18 @@ type
|
||||
proc connect*(connString: string): PMApiDb =
|
||||
result = PMApiDb(conn: open("", "", "", connString))
|
||||
|
||||
generateProcsForModels(PMApiDb, [
|
||||
User,
|
||||
ApiToken,
|
||||
Measure,
|
||||
Measurement,
|
||||
ClientLogEntry
|
||||
])
|
||||
generateProcsForModels([User, ApiToken, Measure, Measurement, ClientLogEntry])
|
||||
|
||||
generateLookup(PMApiDb, User, @["email"])
|
||||
generateLookup(User, @["email"])
|
||||
|
||||
generateLookup(PMApiDb, ApiToken, @["userId"])
|
||||
generateLookup(PMApiDb, ApiToken, @["hashedToken"])
|
||||
generateLookup(ApiToken, @["userId"])
|
||||
generateLookup(ApiToken, @["hashedToken"])
|
||||
|
||||
generateLookup(PMApiDb, Measure, @["userId"])
|
||||
generateLookup(PMApiDb, Measure, @["userId", "id"])
|
||||
generateLookup(PMApiDb, Measure, @["userId", "slug"])
|
||||
generateLookup(Measure, @["userId"])
|
||||
generateLookup(Measure, @["userId", "id"])
|
||||
generateLookup(Measure, @["userId", "slug"])
|
||||
|
||||
generateLookup(PMApiDb, Measurement, @["measureId"])
|
||||
generateLookup(PMApiDb, Measurement, @["measureId", "id"])
|
||||
generateLookup(Measurement, @["measureId"])
|
||||
generateLookup(Measurement, @["measureId", "id"])
|
||||
|
||||
generateLookup(PMApiDb, ClientLogEntry, @["userId"])
|
||||
generateLookup(ClientLogEntry, @["userId"])
|
||||
|
150
api/src/main/nim/personal_measure_apipkg/db_common.nim
Normal file
150
api/src/main/nim/personal_measure_apipkg/db_common.nim
Normal file
@ -0,0 +1,150 @@
|
||||
import db_postgres, macros, options, sequtils, strutils, uuids
|
||||
|
||||
from unicode import capitalize
|
||||
|
||||
import ./db_util
|
||||
|
||||
type NotFoundError* = object of CatchableError
|
||||
|
||||
proc newMutateClauses(): MutateClauses =
|
||||
return MutateClauses(
|
||||
columns: @[],
|
||||
placeholders: @[],
|
||||
values: @[])
|
||||
|
||||
proc createRecord*[T](db: DbConn, rec: T): T =
|
||||
var mc = newMutateClauses()
|
||||
populateMutateClauses(rec, true, mc)
|
||||
|
||||
# Confusingly, getRow allows inserts and updates. We use it to get back the ID
|
||||
# we want from the row.
|
||||
let newRow = db.getRow(sql(
|
||||
"INSERT INTO " & tableName(rec) &
|
||||
" (" & mc.columns.join(",") & ") " &
|
||||
" VALUES (" & mc.placeholders.join(",") & ") " &
|
||||
" RETURNING *"), mc.values)
|
||||
|
||||
result = rowToModel(T, newRow)
|
||||
|
||||
proc updateRecord*[T](db: DbConn, rec: T): bool =
|
||||
var mc = newMutateClauses()
|
||||
populateMutateClauses(rec, false, mc)
|
||||
|
||||
let setClause = zip(mc.columns, mc.placeholders).mapIt(it.a & " = " & it.b).join(",")
|
||||
let numRowsUpdated = db.execAffectedRows(sql(
|
||||
"UPDATE " & tableName(rec) &
|
||||
" SET " & setClause &
|
||||
" WHERE id = ? "), mc.values.concat(@[$rec.id]))
|
||||
|
||||
return numRowsUpdated > 0;
|
||||
|
||||
template deleteRecord*(db: DbConn, modelType: type, id: typed): untyped =
|
||||
db.tryExec(sql("DELETE FROM " & tableName(modelType) & " WHERE id = ?"), $id)
|
||||
|
||||
proc deleteRecord*[T](db: DbConn, rec: T): bool =
|
||||
return db.tryExec(sql("DELETE FROM " & tableName(rec) & " WHERE id = ?"), $rec.id)
|
||||
|
||||
template getRecord*(db: DbConn, modelType: type, id: typed): untyped =
|
||||
let row = db.getRow(sql(
|
||||
"SELECT " & columnNamesForModel(modelType).join(",") &
|
||||
" FROM " & tableName(modelType) &
|
||||
" WHERE id = ?"), @[$id])
|
||||
|
||||
if row.allIt(it.len == 0):
|
||||
raise newException(NotFoundError, "no record for id " & $id)
|
||||
|
||||
rowToModel(modelType, row)
|
||||
|
||||
template findRecordsWhere*(db: DbConn, modelType: type, whereClause: string, values: varargs[string, dbFormat]): untyped =
|
||||
db.getAllRows(sql(
|
||||
"SELECT " & columnNamesForModel(modelType).join(",") &
|
||||
" FROM " & tableName(modelType) &
|
||||
" WHERE " & whereClause), values)
|
||||
.mapIt(rowToModel(modelType, it))
|
||||
|
||||
template getAllRecords*(db: DbConn, modelType: type): untyped =
|
||||
db.getAllRows(sql(
|
||||
"SELECT " & columnNamesForModel(modelType).join(",") &
|
||||
" FROM " & tableName(modelType)))
|
||||
.mapIt(rowToModel(modelType, it))
|
||||
|
||||
template findRecordsBy*(db: DbConn, modelType: type, lookups: seq[tuple[field: string, value: string]]): untyped =
|
||||
db.getAllRows(sql(
|
||||
"SELECT " & columnNamesForModel(modelType).join(",") &
|
||||
" FROM " & tableName(modelType) &
|
||||
" WHERE " & lookups.mapIt(it.field & " = ?").join(" AND ")),
|
||||
lookups.mapIt(it.value))
|
||||
.mapIt(rowToModel(modelType, it))
|
||||
|
||||
macro generateProcsForModels*(modelTypes: openarray[type]): untyped =
|
||||
result = newStmtList()
|
||||
|
||||
for t in modelTypes:
|
||||
let modelName = $(t.getType[1])
|
||||
let getName = ident("get" & modelName)
|
||||
let getAllName = ident("getAll" & modelName & "s")
|
||||
let findWhereName = ident("find" & modelName & "sWhere")
|
||||
let createName = ident("create" & modelName)
|
||||
let updateName = ident("update" & modelName)
|
||||
let deleteName = ident("delete" & modelName)
|
||||
let idType = typeOfColumn(t, "id")
|
||||
result.add quote do:
|
||||
proc `getName`*(db: PMApiDb, id: `idType`): `t` = getRecord(db.conn, `t`, id)
|
||||
proc `getAllName`*(db: PMApiDb): seq[`t`] = getAllRecords(db.conn, `t`)
|
||||
proc `findWhereName`*(db: PMApiDb, whereClause: string, values: varargs[string, dbFormat]): seq[`t`] =
|
||||
return findRecordsWhere(db.conn, `t`, whereClause, values)
|
||||
proc `createName`*(db: PMApiDb, rec: `t`): `t` = createRecord(db.conn, rec)
|
||||
proc `updateName`*(db: PMApiDb, rec: `t`): bool = updateRecord(db.conn, rec)
|
||||
proc `deleteName`*(db: PMApiDb, rec: `t`): bool = deleteRecord(db.conn, rec)
|
||||
proc `deleteName`*(db: PMApiDb, id: `idType`): bool = deleteRecord(db.conn, `t`, id)
|
||||
|
||||
macro generateLookup*(modelType: type, fields: seq[string]): untyped =
|
||||
let fieldNames = fields[1].mapIt($it)
|
||||
let procName = ident("find" & $modelType.getType[1] & "sBy" & fieldNames.mapIt(it.capitalize).join("And"))
|
||||
|
||||
# Create proc skeleton
|
||||
result = quote do:
|
||||
proc `procName`*(db: PMApiDb): seq[`modelType`] =
|
||||
return findRecordsBy(db.conn, `modelType`)
|
||||
|
||||
var callParams = quote do: @[]
|
||||
|
||||
# Add dynamic parameters for the proc definition and inner proc call
|
||||
for n in fieldNames:
|
||||
let paramTuple = newNimNode(nnkPar)
|
||||
paramTuple.add(newColonExpr(ident("field"), newLit(identNameToDb(n))))
|
||||
paramTuple.add(newColonExpr(ident("value"), ident(n)))
|
||||
|
||||
result[3].add(newIdentDefs(ident(n), ident("string")))
|
||||
callParams[1].add(paramTuple)
|
||||
|
||||
result[6][0][0].add(callParams)
|
||||
|
||||
macro generateProcsForFieldLookups*(modelsAndFields: openarray[tuple[t: type, fields: seq[string]]]): untyped =
|
||||
result = newStmtList()
|
||||
|
||||
for i in modelsAndFields:
|
||||
var modelType = i[1][0]
|
||||
let fieldNames = i[1][1][1].mapIt($it)
|
||||
|
||||
let procName = ident("find" & $modelType & "sBy" & fieldNames.mapIt(it.capitalize).join("And"))
|
||||
|
||||
# Create proc skeleton
|
||||
let procDefAST = quote do:
|
||||
proc `procName`*(db: PMApiDb): seq[`modelType`] =
|
||||
return findRecordsBy(db.conn, `modelType`)
|
||||
|
||||
var callParams = quote do: @[]
|
||||
|
||||
# Add dynamic parameters for the proc definition and inner proc call
|
||||
for n in fieldNames:
|
||||
let paramTuple = newNimNode(nnkPar)
|
||||
paramTuple.add(newColonExpr(ident("field"), newLit(n)))
|
||||
paramTuple.add(newColonExpr(ident("value"), ident(n)))
|
||||
|
||||
procDefAST[3].add(newIdentDefs(ident(n), ident("string")))
|
||||
callParams[1].add(paramTuple)
|
||||
|
||||
procDefAST[6][0][0].add(callParams)
|
||||
|
||||
result.add procDefAST
|
300
api/src/main/nim/personal_measure_apipkg/db_util.nim
Normal file
300
api/src/main/nim/personal_measure_apipkg/db_util.nim
Normal file
@ -0,0 +1,300 @@
|
||||
import json, macros, options, sequtils, strutils, times, timeutils, unicode,
|
||||
uuids
|
||||
|
||||
import nre except toSeq
|
||||
|
||||
const UNDERSCORE_RUNE = "_".toRunes[0]
|
||||
const PG_TIMESTAMP_FORMATS = [
|
||||
"yyyy-MM-dd HH:mm:sszz",
|
||||
"yyyy-MM-dd HH:mm:ss'.'fffzz"
|
||||
]
|
||||
|
||||
type
|
||||
MutateClauses* = object
|
||||
columns*: seq[string]
|
||||
placeholders*: seq[string]
|
||||
values*: seq[string]
|
||||
|
||||
# TODO: more complete implementation
|
||||
# see https://github.com/blakeembrey/pluralize
|
||||
proc pluralize(name: string): string =
|
||||
if name[^2..^1] == "ey": return name[0..^3] & "ies"
|
||||
if name[^1] == 'y': return name[0..^2] & "ies"
|
||||
return name & "s"
|
||||
|
||||
macro modelName*(model: object): string =
|
||||
return $model.getTypeInst
|
||||
|
||||
macro modelName*(modelType: type): string =
|
||||
return $modelType.getType[1]
|
||||
|
||||
proc identNameToDb*(name: string): string =
|
||||
let nameInRunes = name.toRunes
|
||||
var prev: Rune
|
||||
var resultRunes = newSeq[Rune]()
|
||||
|
||||
for cur in nameInRunes:
|
||||
if resultRunes.len == 0:
|
||||
resultRunes.add(toLower(cur))
|
||||
elif isLower(prev) and isUpper(cur):
|
||||
resultRunes.add(UNDERSCORE_RUNE)
|
||||
resultRunes.add(toLower(cur))
|
||||
else: resultRunes.add(toLower(cur))
|
||||
|
||||
prev = cur
|
||||
|
||||
return $resultRunes
|
||||
|
||||
proc dbNameToIdent*(name: string): string =
|
||||
let parts = name.split("_")
|
||||
return @[parts[0]].concat(parts[1..^1].mapIt(capitalize(it))).join("")
|
||||
|
||||
proc tableName*(modelType: type): string =
|
||||
return pluralize(modelName(modelType).identNameToDb)
|
||||
|
||||
proc tableName*[T](rec: T): string =
|
||||
return pluralize(modelName(rec).identNameToDb)
|
||||
|
||||
proc dbFormat*(s: string): string = return s
|
||||
|
||||
proc dbFormat*(dt: DateTime): string = return dt.formatIso8601
|
||||
|
||||
proc dbFormat*[T](list: seq[T]): string =
|
||||
return "{" & list.mapIt(dbFormat(it)).join(",") & "}"
|
||||
|
||||
proc dbFormat*[T](item: T): string = return $item
|
||||
|
||||
type DbArrayParseState = enum
|
||||
expectStart, inQuote, inVal, expectEnd
|
||||
|
||||
proc parsePGDatetime*(val: string): DateTime =
|
||||
var errStr = ""
|
||||
for df in PG_TIMESTAMP_FORMATS:
|
||||
try: return val.parse(df)
|
||||
except: errStr &= "\n" & getCurrentExceptionMsg()
|
||||
|
||||
# PostgreSQL does not pad the millisecond value in a datetime out to three
|
||||
# decimal points. If this is a value like `2019-09-29 12:00:00.5Z` We need to
|
||||
# manually catch this and pad it out to something like
|
||||
# `2019-09-29 12:00:00.500Z` so that we can parse it.
|
||||
const millisTruncDatePattern = "(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.)(\\d{1,2})(.*)"
|
||||
let match = val.match(re(millisTruncDatePattern))
|
||||
if match.isSome:
|
||||
let captures = match.get.captures
|
||||
let reformatted = captures[0] & captures[1].alignLeft(3, '0') & captures[2]
|
||||
try: return reformatted.parse(PG_TIMESTAMP_FORMATS[1])
|
||||
except: errStr &= "\n" & getCurrentExceptionMsg()
|
||||
|
||||
raise newException(ValueError, "Cannot parse PG date. Tried:" & errStr)
|
||||
|
||||
proc parseDbArray*(val: string): seq[string] =
|
||||
result = newSeq[string]()
|
||||
|
||||
var parseState = DbArrayParseState.expectStart
|
||||
var curStr = ""
|
||||
var idx = 1
|
||||
var sawEscape = false
|
||||
|
||||
while idx < val.len - 1:
|
||||
var curChar = val[idx]
|
||||
idx += 1
|
||||
|
||||
case parseState:
|
||||
|
||||
of expectStart:
|
||||
if curChar == ' ': continue
|
||||
elif curChar == '"':
|
||||
parseState = inQuote
|
||||
continue
|
||||
else:
|
||||
parseState = inVal
|
||||
|
||||
of expectEnd:
|
||||
if curChar == ' ': continue
|
||||
elif curChar == ',':
|
||||
result.add(curStr)
|
||||
curStr = ""
|
||||
parseState = expectStart
|
||||
continue
|
||||
|
||||
of inQuote:
|
||||
if curChar == '"' and not sawEscape:
|
||||
parseState = expectEnd
|
||||
continue
|
||||
|
||||
of inVal:
|
||||
if curChar == '"' and not sawEscape:
|
||||
raise newException(ValueError, "Invalid DB array value (cannot have '\"' in the middle of an unquoted string).")
|
||||
elif curChar == ',':
|
||||
result.add(curStr)
|
||||
curStr = ""
|
||||
parseState = expectStart
|
||||
continue
|
||||
|
||||
# if we saw an escaped \", add just the ", otherwise add both
|
||||
if sawEscape:
|
||||
if curChar != '"': curStr.add('\\')
|
||||
curStr.add(curChar)
|
||||
sawEscape = false
|
||||
|
||||
elif curChar == '\\':
|
||||
sawEscape = true
|
||||
|
||||
else: curStr.add(curChar)
|
||||
|
||||
if not (parseState == inQuote) and curStr.len > 0:
|
||||
result.add(curStr)
|
||||
|
||||
proc createParseStmt*(t, value: NimNode): NimNode =
|
||||
|
||||
#echo "Creating parse statment for ", t.treeRepr
|
||||
if t.typeKind == ntyObject:
|
||||
|
||||
if t.getType == UUID.getType:
|
||||
result = quote do: parseUUID(`value`)
|
||||
|
||||
elif t.getType == DateTime.getType:
|
||||
result = quote do: parsePGDatetime(`value`)
|
||||
|
||||
elif t.getTypeInst == Option.getType:
|
||||
let innerType = t.getTypeImpl[2][0][0][1]
|
||||
let parseStmt = createParseStmt(innerType, value)
|
||||
result = quote do:
|
||||
if `value`.len == 0: none[`innerType`]()
|
||||
else: some(`parseStmt`)
|
||||
|
||||
else: error "Unknown value object type: " & $t.getTypeInst
|
||||
|
||||
elif t.typeKind == ntyRef:
|
||||
|
||||
if $t.getTypeInst == "JsonNode":
|
||||
result = quote do: parseJson(`value`)
|
||||
|
||||
else:
|
||||
error "Unknown ref type: " & $t.getTypeInst
|
||||
|
||||
elif t.typeKind == ntySequence:
|
||||
let innerType = t[1]
|
||||
|
||||
let parseStmts = createParseStmt(innerType, ident("it"))
|
||||
|
||||
result = quote do: parseDbArray(`value`).mapIt(`parseStmts`)
|
||||
|
||||
elif t.typeKind == ntyString:
|
||||
result = quote do: `value`
|
||||
|
||||
elif t.typeKind == ntyInt:
|
||||
result = quote do: parseInt(`value`)
|
||||
|
||||
elif t.typeKind == ntyBool:
|
||||
result = quote do: "true".startsWith(`value`.toLower)
|
||||
|
||||
else:
|
||||
error "Unknown value type: " & $t.typeKind
|
||||
|
||||
template walkFieldDefs*(t: NimNode, body: untyped) =
|
||||
let tTypeImpl = t.getTypeImpl
|
||||
|
||||
var nodeToItr: NimNode
|
||||
if tTypeImpl.typeKind == ntyObject: nodeToItr = tTypeImpl[2]
|
||||
elif tTypeImpl.typeKind == ntyTypeDesc: nodeToItr = tTypeImpl.getType[1].getType[2]
|
||||
else: error $t & " is not an object or type desc (it's a " & $tTypeImpl.typeKind & ")."
|
||||
|
||||
for fieldDef {.inject.} in nodeToItr.children:
|
||||
# ignore AST nodes that are not field definitions
|
||||
if fieldDef.kind == nnkIdentDefs:
|
||||
let fieldIdent {.inject.} = fieldDef[0]
|
||||
let fieldType {.inject.} = fieldDef[1]
|
||||
body
|
||||
|
||||
elif fieldDef.kind == nnkSym:
|
||||
let fieldIdent {.inject.} = fieldDef
|
||||
let fieldType {.inject.} = fieldDef.getType
|
||||
body
|
||||
|
||||
macro columnNamesForModel*(modelType: typed): seq[string] =
|
||||
var columnNames = newSeq[string]()
|
||||
|
||||
modelType.walkFieldDefs:
|
||||
columnNames.add(identNameToDb($fieldIdent))
|
||||
|
||||
result = newLit(columnNames)
|
||||
|
||||
macro rowToModel*(modelType: typed, row: seq[string]): untyped =
|
||||
|
||||
# Create the object constructor AST node
|
||||
result = newNimNode(nnkObjConstr).add(modelType)
|
||||
|
||||
# Create new colon expressions for each of the property initializations
|
||||
var idx = 0
|
||||
modelType.walkFieldDefs:
|
||||
let itemLookup = quote do: `row`[`idx`]
|
||||
result.add(newColonExpr(
|
||||
fieldIdent,
|
||||
createParseStmt(fieldType, itemLookup)))
|
||||
idx += 1
|
||||
|
||||
macro listFields*(t: typed): untyped =
|
||||
var fields: seq[tuple[n: string, t: string]] = @[]
|
||||
t.walkFieldDefs:
|
||||
if fieldDef.kind == nnkSym: fields.add((n: $fieldIdent, t: fieldType.repr))
|
||||
else: fields.add((n: $fieldIdent, t: $fieldType))
|
||||
|
||||
result = newLit(fields)
|
||||
|
||||
proc typeOfColumn*(modelType: NimNode, colName: string): NimNode =
|
||||
modelType.walkFieldDefs:
|
||||
if $fieldIdent != colName: continue
|
||||
|
||||
if fieldType.typeKind == ntyObject:
|
||||
|
||||
if fieldType.getType == UUID.getType: return ident("UUID")
|
||||
elif fieldType.getType == DateTime.getType: return ident("DateTime")
|
||||
elif fieldType.getType == Option.getType: return ident("Option")
|
||||
else: error "Unknown column type: " & $fieldType.getTypeInst
|
||||
|
||||
else: return fieldType
|
||||
|
||||
raise newException(Exception,
|
||||
"model of type '" & $modelType & "' has no column named '" & colName & "'")
|
||||
|
||||
proc isZero(val: int): bool = return val == 0
|
||||
|
||||
macro populateMutateClauses*(t: typed, newRecord: bool, mc: var MutateClauses): untyped =
|
||||
|
||||
result = newStmtList()
|
||||
|
||||
# iterate over all the object's fields
|
||||
t.walkFieldDefs:
|
||||
|
||||
# grab the field, it's string name, and it's type
|
||||
let fieldName = $fieldIdent
|
||||
|
||||
# we do not update the ID, but we do check: if we're creating a new
|
||||
# record, we should not have an existing ID
|
||||
if fieldName == "id":
|
||||
result.add quote do:
|
||||
if `newRecord` and not `t`.id.isZero:
|
||||
raise newException(
|
||||
AssertionError,
|
||||
"Trying to create a new record, but the record already has an ID (" & $(`t`.id) & ").")
|
||||
|
||||
# if we're looking at an optional field, add logic to check for presence
|
||||
elif fieldType.kind == nnkBracketExpr and
|
||||
fieldType.len > 0 and
|
||||
fieldType[0] == Option.getType:
|
||||
|
||||
result.add quote do:
|
||||
`mc`.columns.add(identNameToDb(`fieldName`))
|
||||
if `t`.`fieldIdent`.isSome:
|
||||
`mc`.placeholders.add("?")
|
||||
`mc`.values.add(dbFormat(`t`.`fieldIdent`.get))
|
||||
else:
|
||||
`mc`.placeholders.add("NULL")
|
||||
|
||||
# otherwise assume we can convert and go ahead.
|
||||
else:
|
||||
result.add quote do:
|
||||
`mc`.columns.add(identNameToDb(`fieldName`))
|
||||
`mc`.placeholders.add("?")
|
||||
`mc`.values.add(dbFormat(`t`.`fieldIdent`))
|
@ -1 +1 @@
|
||||
const PM_API_VERSION* = "0.7.0"
|
||||
const PM_API_VERSION* = "0.6.0"
|
||||
|
@ -46,6 +46,9 @@ user to manage these without a password.
|
||||
pmapi ALL=NOPASSWD: /bin/systemctl stop personal_measure_api.dev.service
|
||||
pmapi ALL=NOPASSWD: /bin/systemctl start personal_measure_api.dev.service
|
||||
|
||||
two systemd
|
||||
service definitions, one for
|
||||
|
||||
### Database
|
||||
|
||||
razgriz-db.jdb-labs.com RDS instance maintains databases for each environment:
|
||||
@ -57,9 +60,17 @@ razgriz-db.jdb-labs.com RDS instance maintains databases for each environment:
|
||||
CloudFront manages the routing of all of the external facing URLs.
|
||||
|
||||
https://pm.jdb-labs.com (CloudFront)
|
||||
├── /api/<path>
|
||||
│ └── https://pmapi.jdb-labs.com/api/
|
||||
│ ├── nginx:80 --> nim/jester:8280
|
||||
│ └── razgriz-db: database personal_measure
|
||||
└── s3://pm.jdb-labs.com/prod/webroot (static HTML)
|
||||
|
||||
https://pm-dev.jdb-labs.com (CloudFront)
|
||||
├── /api/<path>
|
||||
│ └── https://pmapi-dev.jdb-labs.com/api/
|
||||
│ ├── nginx:80 --> nim/jester:8281
|
||||
│ └── razgriz-db: database personal_measure_dev
|
||||
└── s3://pm.jdb-labs.com/dev/webroot (static HTML)
|
||||
|
||||
|
||||
|
@ -5,7 +5,15 @@ variable "aws_region" {
|
||||
default = "us-west-2" # Oregon
|
||||
}
|
||||
|
||||
variable "app_root_url" {
|
||||
variable "deploy_bucket_name" {
|
||||
description = "Name of the S3 bucket to store deployed artifacts, logs, etc."
|
||||
default = "pm.jdb-labs.com"
|
||||
}
|
||||
|
||||
#### Provider Configuration
|
||||
|
||||
provider "aws" {
|
||||
region = var.aws_region
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,28 +1,8 @@
|
||||
provider "aws" {
|
||||
region = var.aws_region
|
||||
}
|
||||
|
||||
resource "aws_s3_bucket" "personal_measure" {
|
||||
bucket = "${var.app_root_url}"
|
||||
bucket = "${var.deploy_bucket_name}"
|
||||
acl = "log-delivery-write"
|
||||
}
|
||||
|
||||
resource "aws_dynamodb_table" "dynamodb_terraform-state-lock" {
|
||||
name = "terraform-state-lock.${var.app_root_url}"
|
||||
hash_key = "LockID"
|
||||
read_capacity = 20
|
||||
write_capacity = 20
|
||||
|
||||
attribute {
|
||||
name = "LockID"
|
||||
type = "S"
|
||||
}
|
||||
|
||||
tags = {
|
||||
Name = "Terraform DynamoDB State Lock Table"
|
||||
}
|
||||
}
|
||||
|
||||
module "dev_env" {
|
||||
source = "./deployed_env"
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
terraform {
|
||||
backend "s3" {
|
||||
bucket = "pm.jdb-labs.com"
|
||||
region = "us-west-2"
|
||||
key = "terraform.tfstate"
|
||||
dynamodb_table = "terraform-state-lock.pm.jdb-labs.com"
|
||||
}
|
||||
}
|
547
operations/terraform/terraform.tfstate
Normal file
547
operations/terraform/terraform.tfstate
Normal file
@ -0,0 +1,547 @@
|
||||
{
|
||||
"version": 4,
|
||||
"terraform_version": "0.12.9",
|
||||
"serial": 13,
|
||||
"lineage": "07ea4679-dcfc-ec03-69c0-9f3b3df53386",
|
||||
"outputs": {},
|
||||
"resources": [
|
||||
{
|
||||
"module": "module.prod_env",
|
||||
"mode": "data",
|
||||
"type": "aws_iam_policy_document",
|
||||
"name": "bucket_access_policy",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"id": "4164925389",
|
||||
"json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/prod/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity EV7VQF8SH3HMM\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity EV7VQF8SH3HMM\"\n }\n }\n ]\n}",
|
||||
"override_json": null,
|
||||
"policy_id": null,
|
||||
"source_json": null,
|
||||
"statement": [
|
||||
{
|
||||
"actions": [
|
||||
"s3:GetObject"
|
||||
],
|
||||
"condition": [],
|
||||
"effect": "Allow",
|
||||
"not_actions": [],
|
||||
"not_principals": [],
|
||||
"not_resources": [],
|
||||
"principals": [
|
||||
{
|
||||
"identifiers": [
|
||||
"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity EV7VQF8SH3HMM"
|
||||
],
|
||||
"type": "AWS"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
"arn:aws:s3:::pm.jdb-labs.com/prod/webroot/*"
|
||||
],
|
||||
"sid": ""
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"s3:ListBucket"
|
||||
],
|
||||
"condition": [],
|
||||
"effect": "Allow",
|
||||
"not_actions": [],
|
||||
"not_principals": [],
|
||||
"not_resources": [],
|
||||
"principals": [
|
||||
{
|
||||
"identifiers": [
|
||||
"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity EV7VQF8SH3HMM"
|
||||
],
|
||||
"type": "AWS"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
"arn:aws:s3:::pm.jdb-labs.com"
|
||||
],
|
||||
"sid": ""
|
||||
}
|
||||
],
|
||||
"version": "2012-10-17"
|
||||
},
|
||||
"depends_on": [
|
||||
"aws_cloudfront_origin_access_identity.origin_access_identity"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"module": "module.dev_env",
|
||||
"mode": "data",
|
||||
"type": "aws_iam_policy_document",
|
||||
"name": "bucket_access_policy",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"id": "672870168",
|
||||
"json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/dev/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ENADNQSO0I1JY\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ENADNQSO0I1JY\"\n }\n }\n ]\n}",
|
||||
"override_json": null,
|
||||
"policy_id": null,
|
||||
"source_json": null,
|
||||
"statement": [
|
||||
{
|
||||
"actions": [
|
||||
"s3:GetObject"
|
||||
],
|
||||
"condition": [],
|
||||
"effect": "Allow",
|
||||
"not_actions": [],
|
||||
"not_principals": [],
|
||||
"not_resources": [],
|
||||
"principals": [
|
||||
{
|
||||
"identifiers": [
|
||||
"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ENADNQSO0I1JY"
|
||||
],
|
||||
"type": "AWS"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
"arn:aws:s3:::pm.jdb-labs.com/dev/webroot/*"
|
||||
],
|
||||
"sid": ""
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"s3:ListBucket"
|
||||
],
|
||||
"condition": [],
|
||||
"effect": "Allow",
|
||||
"not_actions": [],
|
||||
"not_principals": [],
|
||||
"not_resources": [],
|
||||
"principals": [
|
||||
{
|
||||
"identifiers": [
|
||||
"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ENADNQSO0I1JY"
|
||||
],
|
||||
"type": "AWS"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
"arn:aws:s3:::pm.jdb-labs.com"
|
||||
],
|
||||
"sid": ""
|
||||
}
|
||||
],
|
||||
"version": "2012-10-17"
|
||||
},
|
||||
"depends_on": [
|
||||
"aws_cloudfront_origin_access_identity.origin_access_identity"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "data",
|
||||
"type": "aws_iam_policy_document",
|
||||
"name": "cloudfront_access_policy",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"id": "1534115699",
|
||||
"json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/dev/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ENADNQSO0I1JY\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ENADNQSO0I1JY\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/prod/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity EV7VQF8SH3HMM\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity EV7VQF8SH3HMM\"\n }\n }\n ]\n}",
|
||||
"override_json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/prod/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity EV7VQF8SH3HMM\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity EV7VQF8SH3HMM\"\n }\n }\n ]\n}",
|
||||
"policy_id": null,
|
||||
"source_json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/dev/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ENADNQSO0I1JY\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ENADNQSO0I1JY\"\n }\n }\n ]\n}",
|
||||
"statement": null,
|
||||
"version": "2012-10-17"
|
||||
},
|
||||
"depends_on": [
|
||||
"module.dev_env",
|
||||
"module.prod_env"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"module": "module.prod_env",
|
||||
"mode": "managed",
|
||||
"type": "aws_cloudfront_distribution",
|
||||
"name": "s3_distribution",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 1,
|
||||
"attributes": {
|
||||
"active_trusted_signers": {
|
||||
"enabled": "false",
|
||||
"items.#": "0"
|
||||
},
|
||||
"aliases": [
|
||||
"pm.jdb-labs.com"
|
||||
],
|
||||
"arn": "arn:aws:cloudfront::063932952339:distribution/E331OLEUZMJYX2",
|
||||
"cache_behavior": [],
|
||||
"caller_reference": "terraform-20190924171430991900000002",
|
||||
"comment": "Personal Measure prod distribution.",
|
||||
"custom_error_response": [
|
||||
{
|
||||
"error_caching_min_ttl": null,
|
||||
"error_code": 404,
|
||||
"response_code": 200,
|
||||
"response_page_path": "/index.html"
|
||||
}
|
||||
],
|
||||
"default_cache_behavior": [
|
||||
{
|
||||
"allowed_methods": [
|
||||
"GET",
|
||||
"HEAD",
|
||||
"OPTIONS"
|
||||
],
|
||||
"cached_methods": [
|
||||
"GET",
|
||||
"HEAD",
|
||||
"OPTIONS"
|
||||
],
|
||||
"compress": true,
|
||||
"default_ttl": 31536000,
|
||||
"field_level_encryption_id": "",
|
||||
"forwarded_values": [
|
||||
{
|
||||
"cookies": [
|
||||
{
|
||||
"forward": "none",
|
||||
"whitelisted_names": null
|
||||
}
|
||||
],
|
||||
"headers": null,
|
||||
"query_string": false,
|
||||
"query_string_cache_keys": null
|
||||
}
|
||||
],
|
||||
"lambda_function_association": [],
|
||||
"max_ttl": 31536000,
|
||||
"min_ttl": 0,
|
||||
"smooth_streaming": false,
|
||||
"target_origin_id": "S3-PersonalMeasure-prod",
|
||||
"trusted_signers": null,
|
||||
"viewer_protocol_policy": "redirect-to-https"
|
||||
}
|
||||
],
|
||||
"default_root_object": "/index.html",
|
||||
"domain_name": "d1pydbw1mwi6dq.cloudfront.net",
|
||||
"enabled": true,
|
||||
"etag": "E39Y9O0I859AQB",
|
||||
"hosted_zone_id": "Z2FDTNDATAQYW2",
|
||||
"http_version": "http2",
|
||||
"id": "E331OLEUZMJYX2",
|
||||
"in_progress_validation_batches": 0,
|
||||
"is_ipv6_enabled": true,
|
||||
"last_modified_time": "2019-09-24 17:14:34.861 +0000 UTC",
|
||||
"logging_config": [
|
||||
{
|
||||
"bucket": "pm.jdb-labs.com.s3.amazonaws.com",
|
||||
"include_cookies": false,
|
||||
"prefix": "prod/logs/cloudfront"
|
||||
}
|
||||
],
|
||||
"ordered_cache_behavior": [],
|
||||
"origin": [
|
||||
{
|
||||
"custom_header": [],
|
||||
"custom_origin_config": [],
|
||||
"domain_name": "pm.jdb-labs.com.s3.us-west-2.amazonaws.com",
|
||||
"origin_id": "S3-PersonalMeasure-prod",
|
||||
"origin_path": "/prod/webroot",
|
||||
"s3_origin_config": [
|
||||
{
|
||||
"origin_access_identity": "origin-access-identity/cloudfront/EV7VQF8SH3HMM"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"origin_group": [],
|
||||
"price_class": "PriceClass_100",
|
||||
"restrictions": [
|
||||
{
|
||||
"geo_restriction": [
|
||||
{
|
||||
"locations": null,
|
||||
"restriction_type": "none"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"retain_on_delete": false,
|
||||
"status": "Deployed",
|
||||
"tags": {
|
||||
"Environment": "prod"
|
||||
},
|
||||
"viewer_certificate": [
|
||||
{
|
||||
"acm_certificate_arn": "arn:aws:acm:us-east-1:063932952339:certificate/48fe3ce0-4700-4eaa-b433-bb634f47934c",
|
||||
"cloudfront_default_certificate": false,
|
||||
"iam_certificate_id": "",
|
||||
"minimum_protocol_version": "TLSv1",
|
||||
"ssl_support_method": "sni-only"
|
||||
}
|
||||
],
|
||||
"wait_for_deployment": true,
|
||||
"web_acl_id": ""
|
||||
},
|
||||
"private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==",
|
||||
"depends_on": [
|
||||
"aws_cloudfront_origin_access_identity.origin_access_identity"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"module": "module.dev_env",
|
||||
"mode": "managed",
|
||||
"type": "aws_cloudfront_distribution",
|
||||
"name": "s3_distribution",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 1,
|
||||
"attributes": {
|
||||
"active_trusted_signers": {
|
||||
"enabled": "false",
|
||||
"items.#": "0"
|
||||
},
|
||||
"aliases": [
|
||||
"pm-dev.jdb-labs.com"
|
||||
],
|
||||
"arn": "arn:aws:cloudfront::063932952339:distribution/EYDKNEMGBYXK6",
|
||||
"cache_behavior": [],
|
||||
"caller_reference": "terraform-20190924171430991900000001",
|
||||
"comment": "Personal Measure dev distribution.",
|
||||
"custom_error_response": [
|
||||
{
|
||||
"error_caching_min_ttl": null,
|
||||
"error_code": 404,
|
||||
"response_code": 200,
|
||||
"response_page_path": "/index.html"
|
||||
}
|
||||
],
|
||||
"default_cache_behavior": [
|
||||
{
|
||||
"allowed_methods": [
|
||||
"GET",
|
||||
"HEAD",
|
||||
"OPTIONS"
|
||||
],
|
||||
"cached_methods": [
|
||||
"GET",
|
||||
"HEAD",
|
||||
"OPTIONS"
|
||||
],
|
||||
"compress": true,
|
||||
"default_ttl": 31536000,
|
||||
"field_level_encryption_id": "",
|
||||
"forwarded_values": [
|
||||
{
|
||||
"cookies": [
|
||||
{
|
||||
"forward": "none",
|
||||
"whitelisted_names": null
|
||||
}
|
||||
],
|
||||
"headers": null,
|
||||
"query_string": false,
|
||||
"query_string_cache_keys": null
|
||||
}
|
||||
],
|
||||
"lambda_function_association": [],
|
||||
"max_ttl": 31536000,
|
||||
"min_ttl": 0,
|
||||
"smooth_streaming": false,
|
||||
"target_origin_id": "S3-PersonalMeasure-dev",
|
||||
"trusted_signers": null,
|
||||
"viewer_protocol_policy": "redirect-to-https"
|
||||
}
|
||||
],
|
||||
"default_root_object": "/index.html",
|
||||
"domain_name": "d2gk6d79ot5fv3.cloudfront.net",
|
||||
"enabled": true,
|
||||
"etag": "E1DN3CB5IQVST8",
|
||||
"hosted_zone_id": "Z2FDTNDATAQYW2",
|
||||
"http_version": "http2",
|
||||
"id": "EYDKNEMGBYXK6",
|
||||
"in_progress_validation_batches": 0,
|
||||
"is_ipv6_enabled": true,
|
||||
"last_modified_time": "2019-09-24 17:14:32.614 +0000 UTC",
|
||||
"logging_config": [
|
||||
{
|
||||
"bucket": "pm.jdb-labs.com.s3.amazonaws.com",
|
||||
"include_cookies": false,
|
||||
"prefix": "dev/logs/cloudfront"
|
||||
}
|
||||
],
|
||||
"ordered_cache_behavior": [],
|
||||
"origin": [
|
||||
{
|
||||
"custom_header": [],
|
||||
"custom_origin_config": [],
|
||||
"domain_name": "pm.jdb-labs.com.s3.us-west-2.amazonaws.com",
|
||||
"origin_id": "S3-PersonalMeasure-dev",
|
||||
"origin_path": "/dev/webroot",
|
||||
"s3_origin_config": [
|
||||
{
|
||||
"origin_access_identity": "origin-access-identity/cloudfront/ENADNQSO0I1JY"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"origin_group": [],
|
||||
"price_class": "PriceClass_100",
|
||||
"restrictions": [
|
||||
{
|
||||
"geo_restriction": [
|
||||
{
|
||||
"locations": null,
|
||||
"restriction_type": "none"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"retain_on_delete": false,
|
||||
"status": "Deployed",
|
||||
"tags": {
|
||||
"Environment": "dev"
|
||||
},
|
||||
"viewer_certificate": [
|
||||
{
|
||||
"acm_certificate_arn": "arn:aws:acm:us-east-1:063932952339:certificate/48fe3ce0-4700-4eaa-b433-bb634f47934c",
|
||||
"cloudfront_default_certificate": false,
|
||||
"iam_certificate_id": "",
|
||||
"minimum_protocol_version": "TLSv1",
|
||||
"ssl_support_method": "sni-only"
|
||||
}
|
||||
],
|
||||
"wait_for_deployment": true,
|
||||
"web_acl_id": ""
|
||||
},
|
||||
"private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==",
|
||||
"depends_on": [
|
||||
"aws_cloudfront_origin_access_identity.origin_access_identity"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"module": "module.prod_env",
|
||||
"mode": "managed",
|
||||
"type": "aws_cloudfront_origin_access_identity",
|
||||
"name": "origin_access_identity",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"caller_reference": "terraform-20190924170615555500000002",
|
||||
"cloudfront_access_identity_path": "origin-access-identity/cloudfront/EV7VQF8SH3HMM",
|
||||
"comment": "OAI for Personal Measure {$var.environment} environment.",
|
||||
"etag": "E1XJOGSBHHRD9K",
|
||||
"iam_arn": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity EV7VQF8SH3HMM",
|
||||
"id": "EV7VQF8SH3HMM",
|
||||
"s3_canonical_user_id": "3a882d18f05e2fa5a3cabc208bcb8c0e2143166b56c0b8442f5b8b405c203859a3f525afcabc2e52dd1c9799d883a166"
|
||||
},
|
||||
"private": "bnVsbA=="
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"module": "module.dev_env",
|
||||
"mode": "managed",
|
||||
"type": "aws_cloudfront_origin_access_identity",
|
||||
"name": "origin_access_identity",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"caller_reference": "terraform-20190924170615555100000001",
|
||||
"cloudfront_access_identity_path": "origin-access-identity/cloudfront/ENADNQSO0I1JY",
|
||||
"comment": "OAI for Personal Measure {$var.environment} environment.",
|
||||
"etag": "E1K0T63S2F5CYR",
|
||||
"iam_arn": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ENADNQSO0I1JY",
|
||||
"id": "ENADNQSO0I1JY",
|
||||
"s3_canonical_user_id": "6e965a9a0e9034badac65e1ac223e048b6d1b934d146abd32c49634489959a5ee1252e34fb643cd222dde425f2abfcd4"
|
||||
},
|
||||
"private": "bnVsbA=="
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_s3_bucket",
|
||||
"name": "personal_measure",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"acceleration_status": "",
|
||||
"acl": "log-delivery-write",
|
||||
"arn": "arn:aws:s3:::pm.jdb-labs.com",
|
||||
"bucket": "pm.jdb-labs.com",
|
||||
"bucket_domain_name": "pm.jdb-labs.com.s3.amazonaws.com",
|
||||
"bucket_prefix": null,
|
||||
"bucket_regional_domain_name": "pm.jdb-labs.com.s3.us-west-2.amazonaws.com",
|
||||
"cors_rule": [],
|
||||
"force_destroy": false,
|
||||
"hosted_zone_id": "Z3BJ6K6RIION7M",
|
||||
"id": "pm.jdb-labs.com",
|
||||
"lifecycle_rule": [],
|
||||
"logging": [],
|
||||
"object_lock_configuration": [],
|
||||
"policy": null,
|
||||
"region": "us-west-2",
|
||||
"replication_configuration": [],
|
||||
"request_payer": "BucketOwner",
|
||||
"server_side_encryption_configuration": [],
|
||||
"tags": {},
|
||||
"versioning": [
|
||||
{
|
||||
"enabled": false,
|
||||
"mfa_delete": false
|
||||
}
|
||||
],
|
||||
"website": [],
|
||||
"website_domain": null,
|
||||
"website_endpoint": null
|
||||
},
|
||||
"private": "bnVsbA=="
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_s3_bucket_policy",
|
||||
"name": "personal_measure",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"bucket": "pm.jdb-labs.com",
|
||||
"id": "pm.jdb-labs.com",
|
||||
"policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/dev/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ENADNQSO0I1JY\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ENADNQSO0I1JY\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/prod/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity EV7VQF8SH3HMM\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity EV7VQF8SH3HMM\"\n }\n }\n ]\n}"
|
||||
},
|
||||
"private": "bnVsbA==",
|
||||
"depends_on": [
|
||||
"aws_s3_bucket.personal_measure",
|
||||
"data.aws_iam_policy_document.cloudfront_access_policy"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
279
operations/terraform/terraform.tfstate.backup
Normal file
279
operations/terraform/terraform.tfstate.backup
Normal file
@ -0,0 +1,279 @@
|
||||
{
|
||||
"version": 4,
|
||||
"terraform_version": "0.12.9",
|
||||
"serial": 9,
|
||||
"lineage": "07ea4679-dcfc-ec03-69c0-9f3b3df53386",
|
||||
"outputs": {},
|
||||
"resources": [
|
||||
{
|
||||
"module": "module.prod_env",
|
||||
"mode": "data",
|
||||
"type": "aws_iam_policy_document",
|
||||
"name": "bucket_access_policy",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"id": "1727217411",
|
||||
"json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/prod/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_EV7VQF8SH3HMM\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_EV7VQF8SH3HMM\"\n }\n }\n ]\n}",
|
||||
"override_json": null,
|
||||
"policy_id": null,
|
||||
"source_json": null,
|
||||
"statement": [
|
||||
{
|
||||
"actions": [
|
||||
"s3:GetObject"
|
||||
],
|
||||
"condition": [],
|
||||
"effect": "Allow",
|
||||
"not_actions": [],
|
||||
"not_principals": [],
|
||||
"not_resources": [],
|
||||
"principals": [
|
||||
{
|
||||
"identifiers": [
|
||||
"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_EV7VQF8SH3HMM"
|
||||
],
|
||||
"type": "AWS"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
"arn:aws:s3:::pm.jdb-labs.com/prod/webroot/*"
|
||||
],
|
||||
"sid": ""
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"s3:ListBucket"
|
||||
],
|
||||
"condition": [],
|
||||
"effect": "Allow",
|
||||
"not_actions": [],
|
||||
"not_principals": [],
|
||||
"not_resources": [],
|
||||
"principals": [
|
||||
{
|
||||
"identifiers": [
|
||||
"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_EV7VQF8SH3HMM"
|
||||
],
|
||||
"type": "AWS"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
"arn:aws:s3:::pm.jdb-labs.com"
|
||||
],
|
||||
"sid": ""
|
||||
}
|
||||
],
|
||||
"version": "2012-10-17"
|
||||
},
|
||||
"depends_on": [
|
||||
"aws_cloudfront_origin_access_identity.origin_access_identity"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"module": "module.dev_env",
|
||||
"mode": "data",
|
||||
"type": "aws_iam_policy_document",
|
||||
"name": "bucket_access_policy",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"id": "3067586518",
|
||||
"json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/dev/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_ENADNQSO0I1JY\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_ENADNQSO0I1JY\"\n }\n }\n ]\n}",
|
||||
"override_json": null,
|
||||
"policy_id": null,
|
||||
"source_json": null,
|
||||
"statement": [
|
||||
{
|
||||
"actions": [
|
||||
"s3:GetObject"
|
||||
],
|
||||
"condition": [],
|
||||
"effect": "Allow",
|
||||
"not_actions": [],
|
||||
"not_principals": [],
|
||||
"not_resources": [],
|
||||
"principals": [
|
||||
{
|
||||
"identifiers": [
|
||||
"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_ENADNQSO0I1JY"
|
||||
],
|
||||
"type": "AWS"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
"arn:aws:s3:::pm.jdb-labs.com/dev/webroot/*"
|
||||
],
|
||||
"sid": ""
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"s3:ListBucket"
|
||||
],
|
||||
"condition": [],
|
||||
"effect": "Allow",
|
||||
"not_actions": [],
|
||||
"not_principals": [],
|
||||
"not_resources": [],
|
||||
"principals": [
|
||||
{
|
||||
"identifiers": [
|
||||
"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_ENADNQSO0I1JY"
|
||||
],
|
||||
"type": "AWS"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
"arn:aws:s3:::pm.jdb-labs.com"
|
||||
],
|
||||
"sid": ""
|
||||
}
|
||||
],
|
||||
"version": "2012-10-17"
|
||||
},
|
||||
"depends_on": [
|
||||
"aws_cloudfront_origin_access_identity.origin_access_identity"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "data",
|
||||
"type": "aws_iam_policy_document",
|
||||
"name": "cloudfront_access_policy",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"id": "754132408",
|
||||
"json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/dev/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_ENADNQSO0I1JY\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_ENADNQSO0I1JY\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/prod/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_EV7VQF8SH3HMM\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_EV7VQF8SH3HMM\"\n }\n }\n ]\n}",
|
||||
"override_json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/prod/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_EV7VQF8SH3HMM\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_EV7VQF8SH3HMM\"\n }\n }\n ]\n}",
|
||||
"policy_id": null,
|
||||
"source_json": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/dev/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_ENADNQSO0I1JY\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_ENADNQSO0I1JY\"\n }\n }\n ]\n}",
|
||||
"statement": null,
|
||||
"version": "2012-10-17"
|
||||
},
|
||||
"depends_on": [
|
||||
"module.dev_env",
|
||||
"module.prod_env"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"module": "module.prod_env",
|
||||
"mode": "managed",
|
||||
"type": "aws_cloudfront_origin_access_identity",
|
||||
"name": "origin_access_identity",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"caller_reference": "terraform-20190924170615555500000002",
|
||||
"cloudfront_access_identity_path": "origin-access-identity/cloudfront/EV7VQF8SH3HMM",
|
||||
"comment": "OAI for Personal Measure {$var.environment} environment.",
|
||||
"etag": "E1XJOGSBHHRD9K",
|
||||
"iam_arn": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity EV7VQF8SH3HMM",
|
||||
"id": "EV7VQF8SH3HMM",
|
||||
"s3_canonical_user_id": "3a882d18f05e2fa5a3cabc208bcb8c0e2143166b56c0b8442f5b8b405c203859a3f525afcabc2e52dd1c9799d883a166"
|
||||
},
|
||||
"private": "bnVsbA=="
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"module": "module.dev_env",
|
||||
"mode": "managed",
|
||||
"type": "aws_cloudfront_origin_access_identity",
|
||||
"name": "origin_access_identity",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"caller_reference": "terraform-20190924170615555100000001",
|
||||
"cloudfront_access_identity_path": "origin-access-identity/cloudfront/ENADNQSO0I1JY",
|
||||
"comment": "OAI for Personal Measure {$var.environment} environment.",
|
||||
"etag": "E1K0T63S2F5CYR",
|
||||
"iam_arn": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ENADNQSO0I1JY",
|
||||
"id": "ENADNQSO0I1JY",
|
||||
"s3_canonical_user_id": "6e965a9a0e9034badac65e1ac223e048b6d1b934d146abd32c49634489959a5ee1252e34fb643cd222dde425f2abfcd4"
|
||||
},
|
||||
"private": "bnVsbA=="
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_s3_bucket",
|
||||
"name": "personal_measure",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"acceleration_status": "",
|
||||
"acl": "log-delivery-write",
|
||||
"arn": "arn:aws:s3:::pm.jdb-labs.com",
|
||||
"bucket": "pm.jdb-labs.com",
|
||||
"bucket_domain_name": "pm.jdb-labs.com.s3.amazonaws.com",
|
||||
"bucket_prefix": null,
|
||||
"bucket_regional_domain_name": "pm.jdb-labs.com.s3.us-west-2.amazonaws.com",
|
||||
"cors_rule": [],
|
||||
"force_destroy": false,
|
||||
"hosted_zone_id": "Z3BJ6K6RIION7M",
|
||||
"id": "pm.jdb-labs.com",
|
||||
"lifecycle_rule": [],
|
||||
"logging": [],
|
||||
"object_lock_configuration": [],
|
||||
"policy": null,
|
||||
"region": "us-west-2",
|
||||
"replication_configuration": [],
|
||||
"request_payer": "BucketOwner",
|
||||
"server_side_encryption_configuration": [],
|
||||
"tags": {},
|
||||
"versioning": [
|
||||
{
|
||||
"enabled": false,
|
||||
"mfa_delete": false
|
||||
}
|
||||
],
|
||||
"website": [],
|
||||
"website_domain": null,
|
||||
"website_endpoint": null
|
||||
},
|
||||
"private": "bnVsbA=="
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_s3_bucket_policy",
|
||||
"name": "personal_measure",
|
||||
"provider": "provider.aws",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"bucket": "pm.jdb-labs.com",
|
||||
"id": "pm.jdb-labs.com",
|
||||
"policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/dev/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_ENADNQSO0I1JY\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_ENADNQSO0I1JY\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:GetObject\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com/prod/webroot/*\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_EV7VQF8SH3HMM\"\n }\n },\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Action\": \"s3:ListBucket\",\n \"Resource\": \"arn:aws:s3:::pm.jdb-labs.com\",\n \"Principal\": {\n \"AWS\": \"arn:aws:iam::cloudfront:user/CloudFront_Origin_Access_Identity_EV7VQF8SH3HMM\"\n }\n }\n ]\n}"
|
||||
},
|
||||
"private": "bnVsbA==",
|
||||
"depends_on": [
|
||||
"aws_s3_bucket.personal_measure",
|
||||
"data.aws_iam_policy_document.cloudfront_access_policy"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Script to update the version number, commit the changes to the version files,
|
||||
# and tag the new commit.
|
||||
|
||||
set -e
|
||||
|
||||
origDir=$(pwd)
|
||||
rootDir=$(git rev-parse --show-toplevel)
|
||||
cd "$rootDir"
|
||||
|
||||
currentBranch=$(git rev-parse --abbrev-ref HEAD)
|
||||
if [ "$currentBranch" != "develop" ]; then
|
||||
printf "You are currently on the '%s' branch. Is this intended (yes/no)? " "$currentBranch"
|
||||
read -r confirmation
|
||||
|
||||
if [ "$confirmation" != "yes" ]; then exit 1; fi
|
||||
fi
|
||||
|
||||
lastVersion=$(jq -r .version web/package.json)
|
||||
printf "Last version: %s\n" "$lastVersion"
|
||||
printf "New version: "
|
||||
read -r newVersion
|
||||
|
||||
printf "New version will be \"%s\". Is this correct (yes/no)? " "$newVersion"
|
||||
read -r confirmation
|
||||
|
||||
if [ "$confirmation" != "yes" ]; then
|
||||
printf "\n"
|
||||
"$origDir/$0"
|
||||
exit
|
||||
fi
|
||||
|
||||
printf ">> Updating /web/package.json with \"version\": \"%s\"\n" "$newVersion"
|
||||
printf "jq \".version = \\\"%s\\\"\" web/package.json > temp.json\n" "$newVersion"
|
||||
jq ".version = \"${newVersion}\"" web/package.json > temp.json
|
||||
printf "mv temp.json web/package.json\n"
|
||||
mv temp.json web/package.json
|
||||
|
||||
printf ">> Updating /web/package-lock.json with \"version\": \"%s\"\n" "$newVersion"
|
||||
printf "jq \".version = \\\"%s\\\"\" web/package-lock.json > temp.json\n" "$newVersion"
|
||||
jq ".version = \"${newVersion}\"" web/package-lock.json > temp.json
|
||||
printf "mv temp.json web/package-lock.json\n"
|
||||
mv temp.json web/package-lock.json
|
||||
|
||||
printf ">> Updating /api/src/main/nim/personal_measure_apipkg/version.nim with PM_API_VERSION* = \"%s\"" "$newVersion"
|
||||
printf "sed -i \"s/%s/%s/\" api/src/main/nim/personal_measure_apipkg/version.nim" "$lastVersion" "$newVersion"
|
||||
sed -i "s/${lastVersion}/${newVersion}/" api/src/main/nim/personal_measure_apipkg/version.nim
|
||||
|
||||
printf ">> Committing new version.\n"
|
||||
printf "git add web/package.json web/package-lock.json api/src/main/nim/personal_measure_apipkg/version.nim"
|
||||
git add web/package.json web/package-lock.json api/src/main/nim/personal_measure_apipkg/version.nim
|
||||
printf "git commit -m \"Update package version to %s\"\n" "$newVersion"
|
||||
git commit -m "Update package version to ${newVersion}"
|
||||
|
||||
printf ">> Tagging commit.\n"
|
||||
printf "git tag -m \"Version %s\" \"%s\"\n" "$newVersion" "$newVersion"
|
||||
git tag -m "Version ${newVersion}" "${newVersion}"
|
||||
|
8
set-env.sh
Executable file
8
set-env.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
if [[ -z $TARGET_ENV ]]; then
|
||||
echo "TARGET_ENV variable is not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export $(grep -v '^#' .env.$TARGET_ENV | xargs )
|
||||
"$@"
|
@ -1,3 +0,0 @@
|
||||
VUE_APP_PM_API_BASE=https://pmapi.jdb-labs.com/v0
|
||||
VUE_APP_LOG_LEVEL=INFO
|
||||
VUE_APP_API_LOG_LEVEL=ERROR
|
1
web/.env.production
Symbolic link
1
web/.env.production
Symbolic link
@ -0,0 +1 @@
|
||||
../.env.prod
|
20
web/Makefile
20
web/Makefile
@ -1,5 +1,23 @@
|
||||
API_LOG_LEVEL='WARN'
|
||||
LOG_LEVEL='TRACE'
|
||||
|
||||
build-dev:
|
||||
npm run build-dev
|
||||
|
||||
build:
|
||||
npm run build-${TARGET_ENV}
|
||||
npm run build
|
||||
|
||||
serve:
|
||||
VUE_APP_PM_API_BASE=/api \
|
||||
VUE_APP_API_LOG_LEVEL=${API_LOG_LEVEL} \
|
||||
VUE_APP_LOG_LEVEL=${LOG_LEVEL} \
|
||||
npm run serve
|
||||
|
||||
serve-dev: build-dev
|
||||
(cd dist && npx live-server . --port=8080 --entry-file=index.html --proxy=/api:http://localhost:8081/api --no-browser)
|
||||
|
||||
serve-ssl: build-dev
|
||||
(cd dist && \
|
||||
(local-ssl-proxy --source=8443 --target=8080 & \
|
||||
echo `pwd` && \
|
||||
npx live-server . --port=8080 --entry-file=index.html --proxy=/api:http://localhost:8081/api --no-browser))
|
||||
|
397
web/package-lock.json
generated
397
web/package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "personal-measure-web",
|
||||
"version": "0.7.0",
|
||||
"version": "0.4.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -2192,9 +2192,9 @@
|
||||
}
|
||||
},
|
||||
"is-buffer": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
|
||||
"integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A=="
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz",
|
||||
"integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw=="
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
@ -3068,6 +3068,28 @@
|
||||
"integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=",
|
||||
"dev": true
|
||||
},
|
||||
"cacache": {
|
||||
"version": "11.3.2",
|
||||
"resolved": "https://registry.npmjs.org/cacache/-/cacache-11.3.2.tgz",
|
||||
"integrity": "sha512-E0zP4EPGDOaT2chM08Als91eYnf8Z+eH1awwwVsngUmgppfM5jjJ8l3z5vO5p5w/I3LsiXawb1sW0VY65pQABg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bluebird": "^3.5.3",
|
||||
"chownr": "^1.1.1",
|
||||
"figgy-pudding": "^3.5.1",
|
||||
"glob": "^7.1.3",
|
||||
"graceful-fs": "^4.1.15",
|
||||
"lru-cache": "^5.1.1",
|
||||
"mississippi": "^3.0.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"move-concurrently": "^1.0.1",
|
||||
"promise-inflight": "^1.0.1",
|
||||
"rimraf": "^2.6.2",
|
||||
"ssri": "^6.0.1",
|
||||
"unique-filename": "^1.1.1",
|
||||
"y18n": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"cache-base": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz",
|
||||
@ -5878,8 +5900,7 @@
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
@ -5900,14 +5921,12 @@
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@ -5922,20 +5941,17 @@
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@ -6052,8 +6068,7 @@
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@ -6065,7 +6080,6 @@
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@ -6080,7 +6094,6 @@
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
@ -6088,14 +6101,12 @@
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.3.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.2",
|
||||
"yallist": "^3.0.0"
|
||||
@ -6114,7 +6125,6 @@
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
@ -6195,8 +6205,7 @@
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@ -6208,7 +6217,6 @@
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@ -6294,8 +6302,7 @@
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
@ -6331,7 +6338,6 @@
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
@ -6351,7 +6357,6 @@
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
@ -6395,14 +6400,12 @@
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -6651,9 +6654,9 @@
|
||||
}
|
||||
},
|
||||
"globule": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/globule/-/globule-1.3.0.tgz",
|
||||
"integrity": "sha512-YlD4kdMqRCQHrhVdonet4TdRtv1/sZKepvoxNT4Nrhrp5HI8XFfc8kFlGlBn2myBo80aGp8Eft259mbcUJhgSg==",
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/globule/-/globule-1.2.1.tgz",
|
||||
"integrity": "sha512-g7QtgWF4uYSL5/dn71WxubOrS7JVGCnFPEnoeChJmBnyR9Mw8nGoEwOgJL/RC2Te0WhbsEUCejfH8SZNJ+adYQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"glob": "~7.1.1",
|
||||
@ -6690,9 +6693,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"handlebars": {
|
||||
"version": "4.7.3",
|
||||
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.3.tgz",
|
||||
"integrity": "sha512-SRGwSYuNfx8DwHD/6InAPzD6RgeruWLT+B8e8a7gGs8FWgHzlExpTFMEq2IA6QpAfOClpKHy6+8IqTjeBCu6Kg==",
|
||||
"version": "4.3.2",
|
||||
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.3.2.tgz",
|
||||
"integrity": "sha512-LuccMnDrKB72bbClEIucoBNAIMpqmWvIGSKNEngDcYFT6hlCq7ZoCWc26ZT9mr6tfWTJeTswSldoI5LOeezzDQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"neo-async": "^2.6.0",
|
||||
@ -7297,12 +7300,6 @@
|
||||
"integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=",
|
||||
"dev": true
|
||||
},
|
||||
"infer-owner": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz",
|
||||
"integrity": "sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==",
|
||||
"dev": true
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
@ -9815,6 +9812,15 @@
|
||||
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=",
|
||||
"dev": true
|
||||
},
|
||||
"mem": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz",
|
||||
"integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"mimic-fn": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"memory-fs": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz",
|
||||
@ -10346,9 +10352,9 @@
|
||||
}
|
||||
},
|
||||
"node-sass": {
|
||||
"version": "4.13.1",
|
||||
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.13.1.tgz",
|
||||
"integrity": "sha512-TTWFx+ZhyDx1Biiez2nB0L3YrCZ/8oHagaDalbuBSlqXgUPsdkUSzJsVxeDO9LtPB49+Fh3WQl3slABo6AotNw==",
|
||||
"version": "4.12.0",
|
||||
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.12.0.tgz",
|
||||
"integrity": "sha512-A1Iv4oN+Iel6EPv77/HddXErL2a+gZ4uBeZUy+a8O35CFYTXhgA8MgLCWBtwpGZdCvTvQ9d+bQxX/QC36GDPpQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"async-foreach": "^0.1.3",
|
||||
@ -10358,7 +10364,7 @@
|
||||
"get-stdin": "^4.0.1",
|
||||
"glob": "^7.0.3",
|
||||
"in-publish": "^2.0.0",
|
||||
"lodash": "^4.17.15",
|
||||
"lodash": "^4.17.11",
|
||||
"meow": "^3.7.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"nan": "^2.13.2",
|
||||
@ -10416,9 +10422,9 @@
|
||||
}
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.14.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz",
|
||||
"integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==",
|
||||
"version": "2.13.2",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz",
|
||||
"integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==",
|
||||
"dev": true
|
||||
},
|
||||
"strip-ansi": {
|
||||
@ -10792,6 +10798,67 @@
|
||||
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
|
||||
"dev": true
|
||||
},
|
||||
"os-locale": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz",
|
||||
"integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"execa": "^0.7.0",
|
||||
"lcid": "^1.0.0",
|
||||
"mem": "^1.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"cross-spawn": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
|
||||
"integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lru-cache": "^4.0.1",
|
||||
"shebang-command": "^1.2.0",
|
||||
"which": "^1.2.9"
|
||||
}
|
||||
},
|
||||
"execa": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz",
|
||||
"integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cross-spawn": "^5.0.1",
|
||||
"get-stream": "^3.0.0",
|
||||
"is-stream": "^1.1.0",
|
||||
"npm-run-path": "^2.0.0",
|
||||
"p-finally": "^1.0.0",
|
||||
"signal-exit": "^3.0.0",
|
||||
"strip-eof": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"get-stream": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
|
||||
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=",
|
||||
"dev": true
|
||||
},
|
||||
"lru-cache": {
|
||||
"version": "4.1.5",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
|
||||
"integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"pseudomap": "^1.0.2",
|
||||
"yallist": "^2.1.2"
|
||||
}
|
||||
},
|
||||
"yallist": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
|
||||
"integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"os-tmpdir": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
|
||||
@ -13699,99 +13766,41 @@
|
||||
"inherits": "2"
|
||||
}
|
||||
},
|
||||
"terser-webpack-plugin": {
|
||||
"version": "1.4.3",
|
||||
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz",
|
||||
"integrity": "sha512-QMxecFz/gHQwteWwSo5nTc6UaICqN1bMedC5sMtUc7y3Ha3Q8y6ZO0iCR8pq4RJC8Hjf0FEPEHZqcMB/+DFCrA==",
|
||||
"terser": {
|
||||
"version": "3.16.1",
|
||||
"resolved": "https://registry.npmjs.org/terser/-/terser-3.16.1.tgz",
|
||||
"integrity": "sha512-JDJjgleBROeek2iBcSNzOHLKsB/MdDf+E/BOAJ0Tk9r7p9/fVobfv7LMJ/g/k3v9SXdmjZnIlFd5nfn/Rt0Xow==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cacache": "^12.0.2",
|
||||
"find-cache-dir": "^2.1.0",
|
||||
"is-wsl": "^1.1.0",
|
||||
"schema-utils": "^1.0.0",
|
||||
"serialize-javascript": "^2.1.2",
|
||||
"source-map": "^0.6.1",
|
||||
"terser": "^4.1.2",
|
||||
"webpack-sources": "^1.4.0",
|
||||
"worker-farm": "^1.7.0"
|
||||
"commander": "~2.17.1",
|
||||
"source-map": "~0.6.1",
|
||||
"source-map-support": "~0.5.9"
|
||||
},
|
||||
"dependencies": {
|
||||
"bluebird": {
|
||||
"version": "3.7.2",
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
|
||||
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==",
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true
|
||||
},
|
||||
"cacache": {
|
||||
"version": "12.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cacache/-/cacache-12.0.3.tgz",
|
||||
"integrity": "sha512-kqdmfXEGFepesTuROHMs3MpFLWrPkSSpRqOw80RCflZXy/khxaArvFrQ7uJxSUduzAufc6G0g1VUCOZXxWavPw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bluebird": "^3.5.5",
|
||||
"chownr": "^1.1.1",
|
||||
"figgy-pudding": "^3.5.1",
|
||||
"glob": "^7.1.4",
|
||||
"graceful-fs": "^4.1.15",
|
||||
"infer-owner": "^1.0.3",
|
||||
"lru-cache": "^5.1.1",
|
||||
"mississippi": "^3.0.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"move-concurrently": "^1.0.1",
|
||||
"promise-inflight": "^1.0.1",
|
||||
"rimraf": "^2.6.3",
|
||||
"ssri": "^6.0.1",
|
||||
"unique-filename": "^1.1.1",
|
||||
"y18n": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"commander": {
|
||||
"version": "2.20.3",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
|
||||
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||
"dev": true
|
||||
},
|
||||
"find-cache-dir": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz",
|
||||
"integrity": "sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"commondir": "^1.0.1",
|
||||
"make-dir": "^2.0.0",
|
||||
"pkg-dir": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.6",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
|
||||
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"make-dir": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz",
|
||||
"integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"pify": "^4.0.1",
|
||||
"semver": "^5.6.0"
|
||||
}
|
||||
},
|
||||
"pify": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
|
||||
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==",
|
||||
"dev": true
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
"terser-webpack-plugin": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.2.2.tgz",
|
||||
"integrity": "sha512-1DMkTk286BzmfylAvLXwpJrI7dWa5BnFmscV/2dCr8+c56egFcbaeFAl7+sujAjdmpLam21XRdhA4oifLyiWWg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cacache": "^11.0.2",
|
||||
"find-cache-dir": "^2.0.0",
|
||||
"schema-utils": "^1.0.0",
|
||||
"serialize-javascript": "^1.4.0",
|
||||
"source-map": "^0.6.1",
|
||||
"terser": "^3.16.1",
|
||||
"webpack-sources": "^1.1.0",
|
||||
"worker-farm": "^1.5.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"schema-utils": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-1.0.0.tgz",
|
||||
@ -13803,57 +13812,11 @@
|
||||
"ajv-keywords": "^3.1.0"
|
||||
}
|
||||
},
|
||||
"serialize-javascript": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz",
|
||||
"integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==",
|
||||
"dev": true
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true
|
||||
},
|
||||
"source-map-support": {
|
||||
"version": "0.5.16",
|
||||
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.16.tgz",
|
||||
"integrity": "sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"buffer-from": "^1.0.0",
|
||||
"source-map": "^0.6.0"
|
||||
}
|
||||
},
|
||||
"terser": {
|
||||
"version": "4.6.3",
|
||||
"resolved": "https://registry.npmjs.org/terser/-/terser-4.6.3.tgz",
|
||||
"integrity": "sha512-Lw+ieAXmY69d09IIc/yqeBqXpEQIpDGZqT34ui1QWXIUpR2RjbqEkT8X7Lgex19hslSqcWM5iMN2kM11eMsESQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"commander": "^2.20.0",
|
||||
"source-map": "~0.6.1",
|
||||
"source-map-support": "~0.5.12"
|
||||
}
|
||||
},
|
||||
"webpack-sources": {
|
||||
"version": "1.4.3",
|
||||
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz",
|
||||
"integrity": "sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"source-list-map": "^2.0.0",
|
||||
"source-map": "~0.6.1"
|
||||
}
|
||||
},
|
||||
"worker-farm": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.7.0.tgz",
|
||||
"integrity": "sha512-rvw3QTZc8lAxyVrqcSGVm5yP/IJ2UcB3U0graE3LCFoZ0Yn2x4EoVSqJKdB/T5M+FLcRPjz4TDacRf3OCfNUzw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"errno": "~0.1.7"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -15478,6 +15441,15 @@
|
||||
"workbox-build": "^3.6.3"
|
||||
}
|
||||
},
|
||||
"worker-farm": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.6.0.tgz",
|
||||
"integrity": "sha512-6w+3tHbM87WnSWnENBUvA2pxJPLhQUg5LKwUQHq3r+XPhIM+Gh2R5ycbwPCyuGbNg+lPgdcnQUhuC02kJCvffQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"errno": "~0.1.7"
|
||||
}
|
||||
},
|
||||
"wrap-ansi": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
|
||||
@ -15576,16 +15548,16 @@
|
||||
"dev": true
|
||||
},
|
||||
"yargs": {
|
||||
"version": "11.1.1",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-11.1.1.tgz",
|
||||
"integrity": "sha512-PRU7gJrJaXv3q3yQZ/+/X6KBswZiaQ+zOmdprZcouPYtQgvNU35i+68M4b1ZHLZtYFT5QObFLV+ZkmJYcwKdiw==",
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-11.1.0.tgz",
|
||||
"integrity": "sha512-NwW69J42EsCSanF8kyn5upxvjp5ds+t3+udGBeTbFnERA+lF541DDpMawzo4z6W/QrzNM18D+BPMiOBibnFV5A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cliui": "^4.0.0",
|
||||
"decamelize": "^1.1.1",
|
||||
"find-up": "^2.1.0",
|
||||
"get-caller-file": "^1.0.1",
|
||||
"os-locale": "^3.1.0",
|
||||
"os-locale": "^2.0.0",
|
||||
"require-directory": "^2.1.1",
|
||||
"require-main-filename": "^1.0.1",
|
||||
"set-blocking": "^2.0.0",
|
||||
@ -15604,21 +15576,6 @@
|
||||
"locate-path": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"invert-kv": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz",
|
||||
"integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==",
|
||||
"dev": true
|
||||
},
|
||||
"lcid": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz",
|
||||
"integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"invert-kv": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"locate-path": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz",
|
||||
@ -15629,34 +15586,6 @@
|
||||
"path-exists": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"mem": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz",
|
||||
"integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"map-age-cleaner": "^0.1.1",
|
||||
"mimic-fn": "^2.0.0",
|
||||
"p-is-promise": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"mimic-fn": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
|
||||
"integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==",
|
||||
"dev": true
|
||||
},
|
||||
"os-locale": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz",
|
||||
"integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"execa": "^1.0.0",
|
||||
"lcid": "^2.0.0",
|
||||
"mem": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"p-limit": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz",
|
||||
|
@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "personal-measure-web",
|
||||
"version": "0.7.0",
|
||||
"version": "0.6.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build-prod": "vue-cli-service build --mode production",
|
||||
"build": "vue-cli-service build --mode production",
|
||||
"build-dev": "vue-cli-service build --mode development",
|
||||
"lint": "vue-cli-service lint",
|
||||
"test:unit": "vue-cli-service test:unit"
|
||||
@ -50,7 +50,7 @@
|
||||
"babel-core": "7.0.0-bridge.0",
|
||||
"lint-staged": "^8.1.0",
|
||||
"live-server": "^1.2.1",
|
||||
"node-sass": "^4.13.1",
|
||||
"node-sass": "^4.12.0",
|
||||
"sass-loader": "^7.1.0",
|
||||
"ts-jest": "^23.0.0",
|
||||
"typescript": "^3.0.0",
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { LogLevel } from './log-message';
|
||||
import Logger from './logger';
|
||||
import { default as Axios, AxiosInstance } from 'axios';
|
||||
|
||||
const ROOT_LOGGER_NAME = 'ROOT';
|
||||
|
||||
@ -7,6 +8,7 @@ const ROOT_LOGGER_NAME = 'ROOT';
|
||||
export class LogService {
|
||||
|
||||
private loggers: { [key: string]: Logger };
|
||||
private http: AxiosInstance = Axios.create();
|
||||
|
||||
public get ROOT_LOGGER() {
|
||||
return this.loggers[ROOT_LOGGER_NAME];
|
||||
|
@ -32,7 +32,7 @@ export class AuthStoreModule extends VuexModule {
|
||||
// this should be guaranteed by the server (redirect HTTP -> HTTPS)
|
||||
// but we'll do a sanity check just to make sure.
|
||||
if (window.location.protocol === 'https:' ||
|
||||
process.env.NODE_ENV === 'development') { // allow http in dev
|
||||
process.env.NODE_ENV === 'development') { // allow in dev
|
||||
localStorage.setItem(SESSION_KEY, authToken);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,10 @@ const VERSION = {
|
||||
module.exports = {
|
||||
devServer: {
|
||||
proxy: {
|
||||
'/v0': { target: 'http://localhost:8081' }
|
||||
'/api': {
|
||||
pathRewrite: { '^/api': '/v0' },
|
||||
target: 'http://localhost:8081'
|
||||
}
|
||||
},
|
||||
host: 'localhost',
|
||||
disableHostCheck: true
|
||||
|
Reference in New Issue
Block a user