Files
parcer/server/src/models/User.ts

76 lines
1.8 KiB
TypeScript
Raw Normal View History

2024-09-24 17:23:53 +05:30
import { DataTypes, Model, Optional } from 'sequelize';
2024-10-15 21:04:43 +05:30
import sequelize from '../storage/db';
2024-09-24 17:23:53 +05:30
interface UserAttributes {
2024-09-24 17:24:11 +05:30
id: number;
email: string;
password: string;
2024-10-03 03:59:02 +05:30
api_key_name?: string | null;
2024-09-26 17:13:57 +05:30
api_key?: string | null;
proxy_url?: string | null;
proxy_username?: string | null;
proxy_password?: string | null;
2024-09-24 17:23:53 +05:30
}
2024-09-24 17:24:11 +05:30
interface UserCreationAttributes extends Optional<UserAttributes, 'id'> { }
2024-09-24 17:23:53 +05:30
class User extends Model<UserAttributes, UserCreationAttributes> implements UserAttributes {
2024-09-24 17:24:11 +05:30
public id!: number;
public email!: string;
public password!: string;
2024-10-03 03:59:02 +05:30
public api_key_name!: string | null;
2024-09-26 17:13:57 +05:30
public api_key!: string | null;
public proxy_url!: string | null;
public proxy_username!: string | null;
public proxy_password!: string | null;
2024-09-24 17:23:53 +05:30
}
User.init(
2024-09-24 17:24:11 +05:30
{
id: {
2024-09-25 19:37:05 +05:30
type: DataTypes.INTEGER,
2024-09-24 17:24:11 +05:30
autoIncrement: true,
primaryKey: true,
},
email: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
validate: {
isEmail: true,
},
},
password: {
type: DataTypes.STRING,
allowNull: false,
},
2024-10-03 03:59:02 +05:30
api_key_name: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: 'Maxun API Key',
},
2024-09-26 17:13:57 +05:30
api_key: {
type: DataTypes.STRING,
2024-10-02 22:43:14 +05:30
allowNull: true,
2024-09-26 17:13:57 +05:30
},
2024-10-02 22:37:28 +05:30
proxy_url: {
type: DataTypes.STRING,
allowNull: true,
},
proxy_username: {
type: DataTypes.STRING,
allowNull: true,
},
proxy_password: {
type: DataTypes.STRING,
allowNull: true,
},
2024-09-24 17:23:53 +05:30
},
2024-09-24 17:24:11 +05:30
{
sequelize,
tableName: 'user',
}
2024-09-24 17:23:53 +05:30
);
export default User;