Skip to content

Commit 23087b2

Browse files
authored
Merge pull request #3 from RooCodeInc/cte/events-api
2 parents 938418f + 93fc57b commit 23087b2

File tree

29 files changed

+375
-286
lines changed

29 files changed

+375
-286
lines changed

.docker/scripts/postgres/create-databases.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ set -u
66
if [ -n "$POSTGRES_DATABASES" ]; then
77
for db in $(echo $POSTGRES_DATABASES | tr ',' ' '); do
88
echo "Creating $db..."
9-
psql -v ON_ERROR_STOP=1 -c "CREATE DATABASE $db;"
9+
psql -U postgres -v ON_ERROR_STOP=1 -c "CREATE DATABASE $db;"
1010
done
1111
fi

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
BILLING_PLAN_ENV=dev
22

33
VSCODE_EXTENSION_BASE_URL=vscode://RooVeterinaryInc.roo-cline
4+
CURSOR_EXTENSION_BASE_URL=cursor://RooVeterinaryInc.roo-cline
45

56
# Clerk
67
# https://clerk.com/docs/deployments/clerk-environment-variables#sign-in-and-sign-up-redirects

.storybook/preview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import '../src/styles/global.css';
1+
import '../src/styles/globals.css';
22

33
import type { Preview } from '@storybook/react';
44

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default [
2828
},
2929
},
3030
{
31-
ignores: ['dist/**', '.next'],
31+
ignores: ['dist/**', '.next', 'storybook-static'],
3232
},
3333
{
3434
...pluginReact.configs.flat.recommended,

migrations/0000_hesitant_kylun.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TABLE "events" (
2+
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "events_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
3+
"type" text NOT NULL,
4+
"timestamp" bigint NOT NULL,
5+
"properties" json NOT NULL,
6+
"created_at" timestamp DEFAULT now() NOT NULL,
7+
"updated_at" timestamp DEFAULT now() NOT NULL
8+
);

migrations/0000_misty_leo.sql

Lines changed: 0 additions & 12 deletions
This file was deleted.

migrations/meta/0000_snapshot.json

Lines changed: 32 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,64 @@
11
{
2-
"id": "013accf9-070a-47cd-9b49-1318a1c8a237",
2+
"id": "5ab333f5-a980-4564-a919-3d15608505d0",
33
"prevId": "00000000-0000-0000-0000-000000000000",
44
"version": "7",
55
"dialect": "postgresql",
66
"tables": {
7-
"public.organization": {
8-
"name": "organization",
7+
"public.events": {
8+
"name": "events",
99
"schema": "",
1010
"columns": {
1111
"id": {
1212
"name": "id",
13-
"type": "text",
13+
"type": "integer",
1414
"primaryKey": true,
15-
"notNull": true
16-
},
17-
"stripe_customer_id": {
18-
"name": "stripe_customer_id",
19-
"type": "text",
20-
"primaryKey": false,
21-
"notNull": false
15+
"notNull": true,
16+
"identity": {
17+
"type": "always",
18+
"name": "events_id_seq",
19+
"schema": "public",
20+
"increment": "1",
21+
"startWith": "1",
22+
"minValue": "1",
23+
"maxValue": "2147483647",
24+
"cache": "1",
25+
"cycle": false
26+
}
2227
},
23-
"stripe_subscription_id": {
24-
"name": "stripe_subscription_id",
28+
"type": {
29+
"name": "type",
2530
"type": "text",
2631
"primaryKey": false,
27-
"notNull": false
32+
"notNull": true
2833
},
29-
"stripe_subscription_price_id": {
30-
"name": "stripe_subscription_price_id",
31-
"type": "text",
34+
"timestamp": {
35+
"name": "timestamp",
36+
"type": "bigint",
3237
"primaryKey": false,
33-
"notNull": false
38+
"notNull": true
3439
},
35-
"stripe_subscription_status": {
36-
"name": "stripe_subscription_status",
37-
"type": "text",
40+
"properties": {
41+
"name": "properties",
42+
"type": "json",
3843
"primaryKey": false,
39-
"notNull": false
40-
},
41-
"stripe_subscription_current_period_end": {
42-
"name": "stripe_subscription_current_period_end",
43-
"type": "bigint",
44-
"primaryKey": false,
45-
"notNull": false
44+
"notNull": true
4645
},
47-
"updated_at": {
48-
"name": "updated_at",
46+
"created_at": {
47+
"name": "created_at",
4948
"type": "timestamp",
5049
"primaryKey": false,
5150
"notNull": true,
5251
"default": "now()"
5352
},
54-
"created_at": {
55-
"name": "created_at",
53+
"updated_at": {
54+
"name": "updated_at",
5655
"type": "timestamp",
5756
"primaryKey": false,
5857
"notNull": true,
5958
"default": "now()"
6059
}
6160
},
62-
"indexes": {
63-
"stripe_customer_id_idx": {
64-
"name": "stripe_customer_id_idx",
65-
"columns": [
66-
{
67-
"expression": "stripe_customer_id",
68-
"isExpression": false,
69-
"asc": true,
70-
"nulls": "last"
71-
}
72-
],
73-
"isUnique": true,
74-
"concurrently": false,
75-
"method": "btree",
76-
"with": {}
77-
}
78-
},
61+
"indexes": {},
7962
"foreignKeys": {},
8063
"compositePrimaryKeys": {},
8164
"uniqueConstraints": {},

migrations/meta/_journal.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
{
66
"idx": 0,
77
"version": "7",
8-
"when": 1747031111132,
9-
"tag": "0000_misty_leo",
8+
"when": 1747204609794,
9+
"tag": "0000_hesitant_kylun",
1010
"breakpoints": true
1111
}
1212
]

src/app/(authenticated)/extension/sign-in/route.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/app/api/events/route.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { auth } from '@clerk/nextjs/server';
2+
import { NextRequest, NextResponse } from 'next/server';
3+
4+
import { eventSchema } from '@/schemas';
5+
import { db } from '@/db';
6+
import { eventsTable } from '@/db/schema';
7+
8+
export async function POST(request: NextRequest) {
9+
const { userId } = await auth();
10+
11+
if (!userId) {
12+
return NextResponse.json(
13+
{ error: 'Unauthorized request' },
14+
{ status: 401 },
15+
);
16+
}
17+
18+
const payload = await request.json();
19+
const result = eventSchema.safeParse(payload);
20+
21+
if (!result.success) {
22+
return NextResponse.json({ success: false });
23+
}
24+
25+
const [record] = await db.insert(eventsTable).values(result.data).returning();
26+
27+
return NextResponse.json({ success: true, id: record?.id });
28+
}

0 commit comments

Comments
 (0)