All files / postcardotp-backend/src/models apiKeyUsage.js

100% Statements 6/6
100% Branches 0/0
100% Functions 2/2
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44  1x   1x 1x                                                           1x 1x           1x    
// models/apiKeyUsage.js
const { DataTypes } = require("sequelize");
 
module.exports = (sequelize) => {
  const ApiKeyUsage = sequelize.define(
    "ApiKeyUsage",
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        // autoIncrement: true,
        primaryKey: true,
      },
      api_key_id: {
        type: DataTypes.UUID,
        allowNull: false,
      },
      endpoint: {
        type: DataTypes.TEXT,
      },
      ip_address: {
        type: DataTypes.TEXT,
      },
      request_time: {
        type: DataTypes.DATE,
        defaultValue: sequelize.literal("CURRENT_TIMESTAMP"),
      },
    },
    {
      tableName: "tbl_api_key_usage",
      timestamps: false,
    },
  );
 
  ApiKeyUsage.associate = (models) => {
    ApiKeyUsage.belongsTo(models.ApiKey, {
      foreignKey: "api_key_id",
      as: "apiKey",
    });
  };
 
  return ApiKeyUsage;
};