logging cleanup

This commit is contained in:
Ben Allfree 2024-01-10 16:36:28 +00:00
parent 113047034c
commit 5ae159b22f
3 changed files with 17 additions and 14 deletions

View File

@ -16,13 +16,13 @@ routerAdd(
const log = mkLog(`DELETE:instance`)
log(`***TOP OF DELETE`)
log(`TOP OF DELETE`)
let data = new DynamicModel({
id: '',
})
c.bind(data)
log(`***After bind`)
log(`After bind`)
// This is necessary for destructuring to work correctly
data = JSON.parse(JSON.stringify(data))
@ -30,14 +30,14 @@ routerAdd(
const id = c.pathParam('id')
log(
`***vars`,
`vars`,
JSON.stringify({
id,
}),
)
const authRecord = /** @type {models.Record} */ (c.get('authRecord')) // empty if not authenticated as regular auth record
log(`***authRecord`, JSON.stringify(authRecord))
log(`authRecord`, JSON.stringify(authRecord))
if (!authRecord) {
throw new BadRequestError(`Expected authRecord here`)
@ -56,9 +56,9 @@ routerAdd(
}
const path = [$os.getenv('DATA_ROOT'), id].join('/')
log(`***path ${path}`)
log(`path ${path}`)
const res = $os.removeAll(path)
log(`***res`, res)
log(`res`, res)
$app.dao().deleteRecord(record)

View File

@ -1,9 +1,9 @@
/// <reference path="../types/types.d.ts" />
/**
* Migrate version numbers
*/
/** Migrate version numbers */
onAfterBootstrap((e) => {
const { audit, mkLog } = /** @type {Lib} */ (require(`${__hooks}/lib.js`))
const log = mkLog(`bootstrap`)
const records = $app.dao().findRecordsByFilter(`instances`, '1=1')
const { versions } = require(`${__hooks}/versions.js`)
const unrecognized = []
@ -28,5 +28,5 @@ onAfterBootstrap((e) => {
unrecognized.push(v)
}
})
unrecognized.forEach((v) => console.log(`***unrecognized ${v}`))
log({ unrecognized })
})

View File

@ -9,9 +9,12 @@ routerAdd(
'GET',
'/api/userToken/:id',
(c) => {
const { mkLog } = /** @type {Lib} */ (require(`${__hooks}/lib.js`))
const log = mkLog(`user-token`)
const id = c.pathParam('id')
console.log(`***vars`, JSON.stringify({ id }))
log({ id })
if (!id) {
throw new BadRequestError(`User ID is required.`)
@ -21,7 +24,7 @@ routerAdd(
const tokenKey = rec.getString('tokenKey')
const passwordHash = rec.getString('passwordHash')
const email = rec.getString(`email`)
console.log(`***tokenKey`, tokenKey)
log({ email, passwordHash, tokenKey })
return c.json(200, { email, passwordHash, tokenKey })
},