Skip to content

Commit

Permalink
feat(user): add last ip, user-agent and fingerprint on user settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Redm4x committed Nov 26, 2024
1 parent 2da4828 commit bf34dbb
Show file tree
Hide file tree
Showing 18 changed files with 470 additions and 63 deletions.
3 changes: 3 additions & 0 deletions apps/api/drizzle/0007_big_black_widow.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE "userSetting" ADD COLUMN "lastIp" varchar(255);--> statement-breakpoint
ALTER TABLE "userSetting" ADD COLUMN "lastUserAgent" varchar(255);--> statement-breakpoint
ALTER TABLE "userSetting" ADD COLUMN "lastFingerprint" varchar(255);
304 changes: 304 additions & 0 deletions apps/api/drizzle/meta/0007_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,304 @@
{
"id": "b32a687e-d14d-493a-b8ea-af2ad172139c",
"prevId": "d83b4940-34c1-400c-98d9-5a1eb935fe5e",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.user_wallets": {
"name": "user_wallets",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"user_id": {
"name": "user_id",
"type": "uuid",
"primaryKey": false,
"notNull": false
},
"address": {
"name": "address",
"type": "varchar",
"primaryKey": false,
"notNull": false
},
"stripe_customer_id": {
"name": "stripe_customer_id",
"type": "varchar",
"primaryKey": false,
"notNull": false
},
"deployment_allowance": {
"name": "deployment_allowance",
"type": "numeric(20, 2)",
"primaryKey": false,
"notNull": true,
"default": "'0.00'"
},
"fee_allowance": {
"name": "fee_allowance",
"type": "numeric(20, 2)",
"primaryKey": false,
"notNull": true,
"default": "'0.00'"
},
"trial": {
"name": "trial",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"user_wallets_user_id_userSetting_id_fk": {
"name": "user_wallets_user_id_userSetting_id_fk",
"tableFrom": "user_wallets",
"tableTo": "userSetting",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"user_wallets_user_id_unique": {
"name": "user_wallets_user_id_unique",
"nullsNotDistinct": false,
"columns": [
"user_id"
]
},
"user_wallets_address_unique": {
"name": "user_wallets_address_unique",
"nullsNotDistinct": false,
"columns": [
"address"
]
}
}
},
"public.checkout_sessions": {
"name": "checkout_sessions",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "uuid_generate_v4()"
},
"user_id": {
"name": "user_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"session_id": {
"name": "session_id",
"type": "varchar",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"updated_at": {
"name": "updated_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"checkout_sessions_user_id_userSetting_id_fk": {
"name": "checkout_sessions_user_id_userSetting_id_fk",
"tableFrom": "checkout_sessions",
"tableTo": "userSetting",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"checkout_sessions_session_id_unique": {
"name": "checkout_sessions_session_id_unique",
"nullsNotDistinct": false,
"columns": [
"session_id"
]
}
}
},
"public.userSetting": {
"name": "userSetting",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "uuid",
"primaryKey": true,
"notNull": true,
"default": "uuid_generate_v4()"
},
"userId": {
"name": "userId",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"username": {
"name": "username",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"email": {
"name": "email",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"emailVerified": {
"name": "emailVerified",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"stripeCustomerId": {
"name": "stripeCustomerId",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"bio": {
"name": "bio",
"type": "text",
"primaryKey": false,
"notNull": false
},
"subscribedToNewsletter": {
"name": "subscribedToNewsletter",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
},
"youtubeUsername": {
"name": "youtubeUsername",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"twitterUsername": {
"name": "twitterUsername",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"githubUsername": {
"name": "githubUsername",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"last_active_at": {
"name": "last_active_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"lastIp": {
"name": "lastIp",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"lastUserAgent": {
"name": "lastUserAgent",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"lastFingerprint": {
"name": "lastFingerprint",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": false,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"userSetting_userId_unique": {
"name": "userSetting_userId_unique",
"nullsNotDistinct": false,
"columns": [
"userId"
]
},
"userSetting_username_unique": {
"name": "userSetting_username_unique",
"nullsNotDistinct": false,
"columns": [
"username"
]
}
}
}
},
"enums": {},
"schemas": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
7 changes: 7 additions & 0 deletions apps/api/drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@
"when": 1731579448104,
"tag": "0006_skinny_stingray",
"breakpoints": true
},
{
"idx": 7,
"version": "7",
"when": 1732614186052,
"tag": "0007_big_black_widow",
"breakpoints": true
}
]
}
10 changes: 5 additions & 5 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
"@cosmjs/proto-signing": "^0.32.4",
"@cosmjs/stargate": "^0.32.4",
"@dotenvx/dotenvx": "^1.9.0",
"@hono/node-server": "1.4.0",
"@hono/sentry": "^1.0.0",
"@hono/swagger-ui": "0.2.1",
"@hono/zod-openapi": "0.9.5",
"@hono/node-server": "1.13.7",
"@hono/sentry": "^1.2.0",
"@hono/swagger-ui": "0.4.1",
"@hono/zod-openapi": "0.18.0",
"@octokit/rest": "^18.12.0",
"@opentelemetry/instrumentation": "^0.54.0",
"@opentelemetry/instrumentation-http": "^0.54.0",
Expand All @@ -71,7 +71,7 @@
"dotenv-expand": "^11.0.6",
"drizzle-orm": "^0.31.2",
"exponential-backoff": "^3.1.1",
"hono": "3.12.0",
"hono": "4.6.12",
"http-assert": "^1.5.0",
"http-errors": "^2.0.0",
"human-interval": "^2.0.1",
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { RequestContextInterceptor } from "@src/core/services/request-context-in
import { HonoInterceptor } from "@src/core/types/hono-interceptor.type";
import packageJson from "../package.json";
import { chainDb, syncUserSchema, userDb } from "./db/dbConnection";
import { clientInfoMiddleware } from "./middlewares/clientInfoMiddleware";
import { apiRouter } from "./routers/apiRouter";
import { dashboardRouter } from "./routers/dashboardRouter";
import { internalRouter } from "./routers/internalRouter";
Expand Down Expand Up @@ -49,6 +50,7 @@ const scheduler = new Scheduler({
appHono.use(container.resolve(HttpLoggerService).intercept());
appHono.use(container.resolve(RequestContextInterceptor).intercept());
appHono.use(container.resolve<HonoInterceptor>(AuthInterceptor).intercept());
appHono.use(clientInfoMiddleware);
appHono.use("*", async (c: Context, next: Next) => {
const { sentry } = await import("@hono/sentry");
return sentry({
Expand Down
Loading

0 comments on commit bf34dbb

Please sign in to comment.