idea-toolbox
Version:
IDEA's utility functions
33 lines (32 loc) • 1.24 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.APIRequestLog = void 0;
const resource_model_1 = require("./resource.model");
/**
* The log of an API request, in IDEA's format.
*
* Table: `idea_logs`.
*
* Indexes:
* - `logId-timestamp-index` (all).
*/
class APIRequestLog extends resource_model_1.Resource {
load(x) {
super.load(x);
this.logId = this.clean(x.logId, String);
this.timestamp = this.clean(x.timestamp, d => new Date(d).getTime(), Date.now());
this.userId = this.clean(x.userId, String);
this.sort = `${this.timestamp}_${this.userId || null}`;
this.expiresAt = Math.round(this.timestamp / 1000) + 2629800; // cast to seconds, +1 month
this.resource = this.clean(x.resource, String);
this.path = this.clean(x.path, String);
this.resourceId = this.clean(x.resourceId, String);
this.method = this.clean(x.method, String);
this.succeeded = this.clean(x.succeeded, Boolean);
if (x.action)
this.action = this.clean(x.action, String);
if (x.description)
this.description = this.clean(x.description, String);
}
}
exports.APIRequestLog = APIRequestLog;