feat: initial setup backend with default routes and db connection

This commit is contained in:
2024-12-30 01:36:41 +01:00
parent 478a53a0fb
commit 26e6cd0b7e
28 changed files with 3062 additions and 1 deletions

View File

@ -0,0 +1,60 @@
import { DataTypes, Model } from "sequelize";
import { sequelize } from "../database/database";
export class Location extends Model {
public location_id!: string;
public lp_ttn_end_device_uplinks_id!: string;
public wifi_latitude!: number;
public wifi_longitude!: number;
public gnss_latitude!: number;
public gnss_longitude!: number;
public created_at_utc!: Date;
public updated_at_utc!: Date;
}
Location.init(
{
location_id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
allowNull: false,
},
lp_ttn_end_device_uplinks_id: {
type: DataTypes.UUID,
allowNull: false,
},
wifi_latitude: {
type: DataTypes.NUMBER,
allowNull: true,
},
wifi_longitude: {
type: DataTypes.NUMBER,
allowNull: true,
},
gnss_latitude: {
type: DataTypes.NUMBER,
allowNull: true,
},
gnss_longitude: {
type: DataTypes.NUMBER,
allowNull: true,
},
created_at_utc: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
allowNull: false,
},
updated_at_utc: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
allowNull: false,
},
},
{
sequelize,
modelName: "Location",
tableName: "location",
timestamps: false,
}
);

View File

@ -0,0 +1,80 @@
import { DataTypes, Model } from "sequelize";
import { sequelize } from "../database/database";
export class LpTtnEndDeviceUplinks extends Model {
public lp_ttn_end_device_uplinks_id!: string;
public device_id!: string;
public application_ids!: string;
public dev_eui!: string;
public join_eui!: string;
public dev_addr!: string;
public received_at_utc!: Date;
public battery!: number;
public latitude!: number;
public longitude!: number;
public created_at_utc!: Date;
public updated_at_utc!: Date;
}
LpTtnEndDeviceUplinks.init(
{
lp_ttn_end_device_uplinks_id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
allowNull: false,
},
device_id: {
type: DataTypes.STRING,
allowNull: false,
},
application_ids: {
type: DataTypes.STRING,
allowNull: true,
},
dev_eui: {
type: DataTypes.STRING,
allowNull: true,
},
join_eui: {
type: DataTypes.STRING,
allowNull: true,
},
dev_addr: {
type: DataTypes.STRING,
allowNull: true,
},
received_at_utc: {
type: DataTypes.DATE,
allowNull: true,
},
battery: {
type: DataTypes.NUMBER,
allowNull: true,
},
latitude: {
type: DataTypes.NUMBER,
allowNull: true,
},
longitude: {
type: DataTypes.NUMBER,
allowNull: true,
},
created_at_utc: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
allowNull: false,
},
updated_at_utc: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
allowNull: false,
},
},
{
sequelize,
modelName: "LpTtnEndDeviceUplinks",
tableName: "lp_ttn_end_device_uplinks",
timestamps: false,
}
);

View File

@ -0,0 +1,70 @@
import { DataTypes, Model } from "sequelize";
import { sequelize } from "../database/database";
export class TtnGatewayReception extends Model {
public ttn_gateway_reception_id!: string;
public lp_ttn_end_device_uplinks_id!: string;
public gateway_id!: string;
public eui!: string;
public rssi!: number;
public latitude!: number;
public longitude!: number;
public altitude!: number;
public created_at_utc!: Date;
public updated_at_utc!: Date;
}
TtnGatewayReception.init(
{
ttn_gateway_reception_id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
allowNull: false,
},
lp_ttn_end_device_uplinks_id: {
type: DataTypes.UUID,
allowNull: false,
},
gateway_id: {
type: DataTypes.STRING,
allowNull: false,
},
eui: {
type: DataTypes.STRING,
allowNull: false,
},
rssi: {
type: DataTypes.NUMBER,
allowNull: true,
},
latitude: {
type: DataTypes.NUMBER,
allowNull: true,
},
longitude: {
type: DataTypes.NUMBER,
allowNull: true,
},
altitude: {
type: DataTypes.NUMBER,
allowNull: true,
},
created_at_utc: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
allowNull: false,
},
updated_at_utc: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
allowNull: false,
},
},
{
sequelize,
modelName: "TtnGatewayReception",
tableName: "ttn_gateway_reception",
timestamps: false,
}
);

View File

@ -0,0 +1,50 @@
import { DataTypes, Model } from "sequelize";
import { sequelize } from "../database/database";
export class WifiScan extends Model {
public wifi_scan_id!: string;
public lp_ttn_end_device_uplinks_id!: string;
public mac!: string;
public rssi!: number;
public created_at_utc!: Date;
public updated_at_utc!: Date;
}
WifiScan.init(
{
wifi_scan_id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
allowNull: false,
},
lp_ttn_end_device_uplinks_id: {
type: DataTypes.UUID,
allowNull: false,
},
mac: {
type: DataTypes.STRING,
allowNull: false,
},
rssi: {
type: DataTypes.NUMBER,
allowNull: true,
},
created_at_utc: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
allowNull: false,
},
updated_at_utc: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
allowNull: false,
},
},
{
sequelize,
modelName: "WifiScan",
tableName: "wifi_scan",
timestamps: false,
}
);