Fix database model associations and update API route

This commit is contained in:
newtbot
2024-01-27 20:15:29 +08:00
parent 6190cb63cd
commit d491750916
14 changed files with 61 additions and 164 deletions

View File

@ -107,6 +107,6 @@ const sensorModel = sequelize.define(
}
);
sensorModel.belongsTo(locationModel);
//sensorModel.belongsTo(locationModel);
module.exports = { sensorModel };

View File

@ -3,7 +3,7 @@ const { Sequelize, DataTypes } = require("sequelize");
const { sequelize } = require("../mySQL");
const { userModel } = require("./userModel");
sequelize.sync();
//sequelize.sync();
const tokenModel = sequelize.define(
"token",
{
@ -48,6 +48,14 @@ const tokenModel = sequelize.define(
isIn: [["canRead", "canWrite",]],
},
},
isKey: {
type: DataTypes.STRING,
allowNull: true,
length: 45,
validate:{
isIn: [["isKey" , "isNotKey"]],
}
},
expiration: {
type: DataTypes.DATE,
allowNull: false,

View File

@ -15,7 +15,7 @@ const sequelize = new Sequelize(
attributeBehavior: 'escape',
dialectOptions: {
ssl: {
ca: fs.readFileSync(path.resolve(__dirname, '../cert/DigiCertGlobalRootCA.crt.pem')),
ca: fs.readFileSync(path.resolve(__dirname, '../cert/DigiCertGlobalRootCA.crt_3.pem')),
},
},