30 lines
749 B
JavaScript
30 lines
749 B
JavaScript
|
const { Model } = require('flitter-orm')
|
||
|
|
||
|
class FrontEndErrorModel extends Model {
|
||
|
static get schema() {
|
||
|
return {
|
||
|
user_agent: String,
|
||
|
logged_at: { type: Date, default: () => new Date },
|
||
|
user_id: String,
|
||
|
session_id: String,
|
||
|
full_url: String,
|
||
|
trace: String,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static async log(request) {
|
||
|
const err = new this({
|
||
|
user_agent: request.get('user-agent'),
|
||
|
user_id: request?.user?.id,
|
||
|
session_id: request.sessionID,
|
||
|
full_url: request.body.full_url,
|
||
|
trace: request.body.trace,
|
||
|
})
|
||
|
|
||
|
await err.save()
|
||
|
return err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = exports = FrontEndErrorModel
|