WIP token

This commit is contained in:
newtbot
2024-01-16 04:43:39 +08:00
parent 290d0653d9
commit 7e4b2d8026
19 changed files with 534 additions and 77 deletions

View File

@ -5,8 +5,8 @@ const { userModel } = require("./userModel");
sequelize.sync();
const apikeyModel = sequelize.define(
"apikey",
{
"apikey",
{
id: {
type: DataTypes.INTEGER,
allowNull: true,
@ -16,39 +16,39 @@ const apikeyModel = sequelize.define(
isNumeric: true,
},
},
userid:{
type: DataTypes.INTEGER,
allowNull: false,
validate: {
isNumeric: true,
},
//fk
references: {
model: userModel,
key: "id",
},
},
apikey: {
type: DataTypes.STRING,
allowNull: false,
length: 255,
unique: true,
validate: {
notEmpty: true,
len: [1, 255],
},
},
permission: {
type: DataTypes.STRING,
allowNull: false,
length: 255,
validate: {
notEmpty: true,
len: [1, 255],
isIn: [['canRead' , 'canWrite']],
},
},
createdAt: {
userid: {
type: DataTypes.INTEGER,
allowNull: false,
validate: {
isNumeric: true,
},
//fk
references: {
model: userModel,
key: "id",
},
},
apikey: {
type: DataTypes.STRING,
allowNull: false,
length: 255,
unique: true,
validate: {
notEmpty: true,
len: [1, 255],
},
},
permission: {
type: DataTypes.STRING,
allowNull: false,
length: 255,
validate: {
notEmpty: true,
len: [1, 255],
isIn: [["canRead", "canWrite"]],
},
},
createdAt: {
type: DataTypes.DATE,
allowNull: true,
},
@ -56,11 +56,10 @@ const apikeyModel = sequelize.define(
type: DataTypes.DATE,
allowNull: true,
},
},
{
timestamps: true,
}
)
},
{
timestamps: true,
}
);
module.exports = { apikeyModel };