This repository has been archived on 2025-02-19. You can view files and clone it, but cannot push or open issues or pull requests.
Matheus Sampaio Queiroga e6cab72032 Init pages and two routers
Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
2024-02-03 21:12:51 -03:00

64 lines
1.3 KiB
TypeScript

import { DataTypes, InferAttributes, InferCreationAttributes, Model } from "sequelize";
import { dbConection } from "./db.js";
export const modelName = "wg_peer";
export type Peer = InferAttributes<wgPeer, { omit: never; }>
export class wgPeer extends Model<InferAttributes<wgPeer>, InferCreationAttributes<wgPeer>> {
declare id?: number;
interfaceOwner: number;
owner: number;
privateKey: string;
presharedKey?: string;
uploadStats: number;
downloadStats: number;
IPv4?: string;
IPv6?: string;
};
wgPeer.init({
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true
},
interfaceOwner: {
type: DataTypes.INTEGER,
allowNull: false,
},
owner: {
type: DataTypes.INTEGER,
allowNull: false,
},
privateKey: {
type: DataTypes.CHAR(44),
allowNull: false,
unique: true
},
presharedKey: {
type: DataTypes.CHAR(44),
allowNull: true,
unique: true
},
uploadStats: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
},
downloadStats: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
},
IPv4: {
type: DataTypes.CHAR,
unique: true,
},
IPv6: {
type: DataTypes.CHAR,
unique: true,
},
}, { sequelize: dbConection, modelName });
wgPeer.sync().then(async () => {
if (await wgPeer.count() === 0) {}
});