@zodic/shared 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,476 @@
1
+ {
2
+ "version": "6",
3
+ "dialect": "sqlite",
4
+ "id": "8407b87a-3217-4bb5-a09d-2d0744e5eea1",
5
+ "prevId": "5d65ee31-0953-4f67-a331-c2ba1704e37b",
6
+ "tables": {
7
+ "astrological_data": {
8
+ "name": "astrological_data",
9
+ "columns": {
10
+ "id": {
11
+ "name": "id",
12
+ "type": "text",
13
+ "primaryKey": true,
14
+ "notNull": true,
15
+ "autoincrement": false
16
+ },
17
+ "user_id": {
18
+ "name": "user_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true,
22
+ "autoincrement": false
23
+ },
24
+ "planet": {
25
+ "name": "planet",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": true,
29
+ "autoincrement": false
30
+ },
31
+ "sign": {
32
+ "name": "sign",
33
+ "type": "text",
34
+ "primaryKey": false,
35
+ "notNull": true,
36
+ "autoincrement": false
37
+ },
38
+ "house": {
39
+ "name": "house",
40
+ "type": "integer",
41
+ "primaryKey": false,
42
+ "notNull": true,
43
+ "autoincrement": false
44
+ },
45
+ "full_degree": {
46
+ "name": "full_degree",
47
+ "type": "real",
48
+ "primaryKey": false,
49
+ "notNull": false,
50
+ "autoincrement": false
51
+ },
52
+ "norm_degree": {
53
+ "name": "norm_degree",
54
+ "type": "real",
55
+ "primaryKey": false,
56
+ "notNull": false,
57
+ "autoincrement": false
58
+ },
59
+ "speed": {
60
+ "name": "speed",
61
+ "type": "real",
62
+ "primaryKey": false,
63
+ "notNull": false,
64
+ "autoincrement": false
65
+ },
66
+ "is_retro": {
67
+ "name": "is_retro",
68
+ "type": "integer",
69
+ "primaryKey": false,
70
+ "notNull": false,
71
+ "autoincrement": false
72
+ }
73
+ },
74
+ "indexes": {
75
+ "astrological_data_user_id_idx": {
76
+ "name": "astrological_data_user_id_idx",
77
+ "columns": [
78
+ "user_id"
79
+ ],
80
+ "isUnique": false
81
+ }
82
+ },
83
+ "foreignKeys": {
84
+ "astrological_data_user_id_users_id_fk": {
85
+ "name": "astrological_data_user_id_users_id_fk",
86
+ "tableFrom": "astrological_data",
87
+ "tableTo": "users",
88
+ "columnsFrom": [
89
+ "user_id"
90
+ ],
91
+ "columnsTo": [
92
+ "id"
93
+ ],
94
+ "onDelete": "cascade",
95
+ "onUpdate": "no action"
96
+ }
97
+ },
98
+ "compositePrimaryKeys": {},
99
+ "uniqueConstraints": {},
100
+ "checkConstraints": {}
101
+ },
102
+ "generations": {
103
+ "name": "generations",
104
+ "columns": {
105
+ "id": {
106
+ "name": "id",
107
+ "type": "text",
108
+ "primaryKey": true,
109
+ "notNull": true,
110
+ "autoincrement": false
111
+ },
112
+ "user_id": {
113
+ "name": "user_id",
114
+ "type": "text",
115
+ "primaryKey": false,
116
+ "notNull": true,
117
+ "autoincrement": false
118
+ },
119
+ "product_id": {
120
+ "name": "product_id",
121
+ "type": "text",
122
+ "primaryKey": false,
123
+ "notNull": true,
124
+ "autoincrement": false
125
+ },
126
+ "type": {
127
+ "name": "type",
128
+ "type": "text",
129
+ "primaryKey": false,
130
+ "notNull": true,
131
+ "autoincrement": false
132
+ },
133
+ "image_id": {
134
+ "name": "image_id",
135
+ "type": "text",
136
+ "primaryKey": false,
137
+ "notNull": false,
138
+ "autoincrement": false
139
+ },
140
+ "image_url": {
141
+ "name": "image_url",
142
+ "type": "text",
143
+ "primaryKey": false,
144
+ "notNull": false,
145
+ "autoincrement": false
146
+ },
147
+ "report_content": {
148
+ "name": "report_content",
149
+ "type": "text",
150
+ "primaryKey": false,
151
+ "notNull": false,
152
+ "autoincrement": false
153
+ },
154
+ "external_source_url": {
155
+ "name": "external_source_url",
156
+ "type": "text",
157
+ "primaryKey": false,
158
+ "notNull": false,
159
+ "autoincrement": false
160
+ },
161
+ "created_at": {
162
+ "name": "created_at",
163
+ "type": "text",
164
+ "primaryKey": false,
165
+ "notNull": false,
166
+ "autoincrement": false,
167
+ "default": "'CURRENT_TIMESTAMP'"
168
+ },
169
+ "metadata": {
170
+ "name": "metadata",
171
+ "type": "text",
172
+ "primaryKey": false,
173
+ "notNull": false,
174
+ "autoincrement": false
175
+ }
176
+ },
177
+ "indexes": {
178
+ "generations_user_id_idx": {
179
+ "name": "generations_user_id_idx",
180
+ "columns": [
181
+ "user_id"
182
+ ],
183
+ "isUnique": false
184
+ },
185
+ "generations_product_id_idx": {
186
+ "name": "generations_product_id_idx",
187
+ "columns": [
188
+ "product_id"
189
+ ],
190
+ "isUnique": false
191
+ },
192
+ "generations_user_id_product_id_idx": {
193
+ "name": "generations_user_id_product_id_idx",
194
+ "columns": [
195
+ "user_id",
196
+ "product_id"
197
+ ],
198
+ "isUnique": false
199
+ }
200
+ },
201
+ "foreignKeys": {
202
+ "generations_user_id_users_id_fk": {
203
+ "name": "generations_user_id_users_id_fk",
204
+ "tableFrom": "generations",
205
+ "tableTo": "users",
206
+ "columnsFrom": [
207
+ "user_id"
208
+ ],
209
+ "columnsTo": [
210
+ "id"
211
+ ],
212
+ "onDelete": "cascade",
213
+ "onUpdate": "no action"
214
+ },
215
+ "generations_product_id_products_id_fk": {
216
+ "name": "generations_product_id_products_id_fk",
217
+ "tableFrom": "generations",
218
+ "tableTo": "products",
219
+ "columnsFrom": [
220
+ "product_id"
221
+ ],
222
+ "columnsTo": [
223
+ "id"
224
+ ],
225
+ "onDelete": "set null",
226
+ "onUpdate": "no action"
227
+ }
228
+ },
229
+ "compositePrimaryKeys": {},
230
+ "uniqueConstraints": {},
231
+ "checkConstraints": {}
232
+ },
233
+ "products": {
234
+ "name": "products",
235
+ "columns": {
236
+ "id": {
237
+ "name": "id",
238
+ "type": "text",
239
+ "primaryKey": true,
240
+ "notNull": true,
241
+ "autoincrement": false
242
+ },
243
+ "name": {
244
+ "name": "name",
245
+ "type": "text",
246
+ "primaryKey": false,
247
+ "notNull": true,
248
+ "autoincrement": false
249
+ },
250
+ "description": {
251
+ "name": "description",
252
+ "type": "text",
253
+ "primaryKey": false,
254
+ "notNull": false,
255
+ "autoincrement": false
256
+ },
257
+ "created_at": {
258
+ "name": "created_at",
259
+ "type": "text",
260
+ "primaryKey": false,
261
+ "notNull": true,
262
+ "autoincrement": false,
263
+ "default": "CURRENT_TIMESTAMP"
264
+ }
265
+ },
266
+ "indexes": {
267
+ "products_name_unique": {
268
+ "name": "products_name_unique",
269
+ "columns": [
270
+ "name"
271
+ ],
272
+ "isUnique": true
273
+ },
274
+ "products_name_idx": {
275
+ "name": "products_name_idx",
276
+ "columns": [
277
+ "name"
278
+ ],
279
+ "isUnique": false
280
+ }
281
+ },
282
+ "foreignKeys": {},
283
+ "compositePrimaryKeys": {},
284
+ "uniqueConstraints": {},
285
+ "checkConstraints": {}
286
+ },
287
+ "tokens": {
288
+ "name": "tokens",
289
+ "columns": {
290
+ "id": {
291
+ "name": "id",
292
+ "type": "text",
293
+ "primaryKey": true,
294
+ "notNull": true,
295
+ "autoincrement": false
296
+ },
297
+ "user_id": {
298
+ "name": "user_id",
299
+ "type": "text",
300
+ "primaryKey": false,
301
+ "notNull": true,
302
+ "autoincrement": false
303
+ },
304
+ "refresh_token": {
305
+ "name": "refresh_token",
306
+ "type": "text",
307
+ "primaryKey": false,
308
+ "notNull": true,
309
+ "autoincrement": false
310
+ },
311
+ "expires_at": {
312
+ "name": "expires_at",
313
+ "type": "text",
314
+ "primaryKey": false,
315
+ "notNull": true,
316
+ "autoincrement": false
317
+ },
318
+ "created_at": {
319
+ "name": "created_at",
320
+ "type": "text",
321
+ "primaryKey": false,
322
+ "notNull": true,
323
+ "autoincrement": false,
324
+ "default": "CURRENT_TIMESTAMP"
325
+ }
326
+ },
327
+ "indexes": {
328
+ "tokens_refresh_token_unique": {
329
+ "name": "tokens_refresh_token_unique",
330
+ "columns": [
331
+ "refresh_token"
332
+ ],
333
+ "isUnique": true
334
+ },
335
+ "tokens_user_id_idx": {
336
+ "name": "tokens_user_id_idx",
337
+ "columns": [
338
+ "user_id"
339
+ ],
340
+ "isUnique": false
341
+ }
342
+ },
343
+ "foreignKeys": {
344
+ "tokens_user_id_users_id_fk": {
345
+ "name": "tokens_user_id_users_id_fk",
346
+ "tableFrom": "tokens",
347
+ "tableTo": "users",
348
+ "columnsFrom": [
349
+ "user_id"
350
+ ],
351
+ "columnsTo": [
352
+ "id"
353
+ ],
354
+ "onDelete": "cascade",
355
+ "onUpdate": "no action"
356
+ }
357
+ },
358
+ "compositePrimaryKeys": {},
359
+ "uniqueConstraints": {},
360
+ "checkConstraints": {}
361
+ },
362
+ "users": {
363
+ "name": "users",
364
+ "columns": {
365
+ "id": {
366
+ "name": "id",
367
+ "type": "text",
368
+ "primaryKey": true,
369
+ "notNull": true,
370
+ "autoincrement": false
371
+ },
372
+ "email": {
373
+ "name": "email",
374
+ "type": "text",
375
+ "primaryKey": false,
376
+ "notNull": true,
377
+ "autoincrement": false
378
+ },
379
+ "name": {
380
+ "name": "name",
381
+ "type": "text",
382
+ "primaryKey": false,
383
+ "notNull": true,
384
+ "autoincrement": false
385
+ },
386
+ "profile_image": {
387
+ "name": "profile_image",
388
+ "type": "text",
389
+ "primaryKey": false,
390
+ "notNull": false,
391
+ "autoincrement": false
392
+ },
393
+ "user_photo_id": {
394
+ "name": "user_photo_id",
395
+ "type": "text",
396
+ "primaryKey": false,
397
+ "notNull": false,
398
+ "autoincrement": false
399
+ },
400
+ "user_photo_url": {
401
+ "name": "user_photo_url",
402
+ "type": "text",
403
+ "primaryKey": false,
404
+ "notNull": false,
405
+ "autoincrement": false
406
+ },
407
+ "gender": {
408
+ "name": "gender",
409
+ "type": "text",
410
+ "primaryKey": false,
411
+ "notNull": false,
412
+ "autoincrement": false
413
+ },
414
+ "birth_date_time": {
415
+ "name": "birth_date_time",
416
+ "type": "text",
417
+ "primaryKey": false,
418
+ "notNull": false,
419
+ "autoincrement": false
420
+ },
421
+ "latitude": {
422
+ "name": "latitude",
423
+ "type": "real",
424
+ "primaryKey": false,
425
+ "notNull": false,
426
+ "autoincrement": false
427
+ },
428
+ "longitude": {
429
+ "name": "longitude",
430
+ "type": "real",
431
+ "primaryKey": false,
432
+ "notNull": false,
433
+ "autoincrement": false
434
+ },
435
+ "created_at": {
436
+ "name": "created_at",
437
+ "type": "text",
438
+ "primaryKey": false,
439
+ "notNull": true,
440
+ "autoincrement": false,
441
+ "default": "CURRENT_TIMESTAMP"
442
+ }
443
+ },
444
+ "indexes": {
445
+ "users_email_unique": {
446
+ "name": "users_email_unique",
447
+ "columns": [
448
+ "email"
449
+ ],
450
+ "isUnique": true
451
+ },
452
+ "users_email_idx": {
453
+ "name": "users_email_idx",
454
+ "columns": [
455
+ "email"
456
+ ],
457
+ "isUnique": false
458
+ }
459
+ },
460
+ "foreignKeys": {},
461
+ "compositePrimaryKeys": {},
462
+ "uniqueConstraints": {},
463
+ "checkConstraints": {}
464
+ }
465
+ },
466
+ "views": {},
467
+ "enums": {},
468
+ "_meta": {
469
+ "schemas": {},
470
+ "tables": {},
471
+ "columns": {}
472
+ },
473
+ "internal": {
474
+ "indexes": {}
475
+ }
476
+ }
@@ -8,6 +8,41 @@
8
8
  "when": 1733941526291,
9
9
  "tag": "0000_flowery_meggan",
10
10
  "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "6",
15
+ "when": 1734826111680,
16
+ "tag": "0001_equal_aaron_stack",
17
+ "breakpoints": true
18
+ },
19
+ {
20
+ "idx": 2,
21
+ "version": "6",
22
+ "when": 1734826298520,
23
+ "tag": "0002_past_sunspot",
24
+ "breakpoints": true
25
+ },
26
+ {
27
+ "idx": 3,
28
+ "version": "6",
29
+ "when": 1734838305184,
30
+ "tag": "0003_swift_pet_avengers",
31
+ "breakpoints": true
32
+ },
33
+ {
34
+ "idx": 4,
35
+ "version": "6",
36
+ "when": 1734838568267,
37
+ "tag": "0004_hesitant_katie_power",
38
+ "breakpoints": true
39
+ },
40
+ {
41
+ "idx": 5,
42
+ "version": "6",
43
+ "when": 1734839869486,
44
+ "tag": "0005_noisy_marvex",
45
+ "breakpoints": true
11
46
  }
12
47
  ]
13
48
  }
package/db/schema.ts CHANGED
@@ -10,16 +10,17 @@ import {
10
10
  export const users = sqliteTable(
11
11
  'users',
12
12
  {
13
- id: text('id').primaryKey(),
13
+ id: text('id')
14
+ .primaryKey(),
14
15
  email: text('email').notNull().unique(),
15
16
  name: text('name').notNull(),
16
17
  profileImage: text('profile_image'),
17
18
  userPhotoId: text('user_photo_id'),
18
19
  userPhotoUrl: text('user_photo_url'),
19
20
  gender: text('gender'),
20
- birthDateTime: text('birth_date_time').notNull(),
21
- latitude: real('latitude').notNull(),
22
- longitude: real('longitude').notNull(),
21
+ birthDateTime: text('birth_date_time'),
22
+ latitude: real('latitude'),
23
+ longitude: real('longitude'),
23
24
  createdAt: text('created_at')
24
25
  .default(sql`CURRENT_TIMESTAMP`)
25
26
  .notNull(),
@@ -30,17 +31,18 @@ export const users = sqliteTable(
30
31
  export const astrologicalData = sqliteTable(
31
32
  'astrological_data',
32
33
  {
33
- id: text('id').primaryKey(),
34
+ id: text('id')
35
+ .primaryKey(),
34
36
  userId: text('user_id')
35
37
  .notNull()
36
38
  .references(() => users.id, { onDelete: 'cascade' }),
37
39
  planet: text('planet').notNull(), // Planet name (e.g., "Sun", "Moon")
38
40
  sign: text('sign').notNull(), // Zodiac sign (e.g., "Sagittarius")
39
41
  house: integer('house').notNull(), // House number (1-12)
40
- fullDegree: real('full_degree').notNull(), // Full degree in 360° system
41
- normDegree: real('norm_degree').notNull(), // Degree within the sign (0-29°)
42
- speed: real('speed').notNull(), // Speed of the planet
43
- isRetro: integer('is_retro').notNull(), // 0 (false) or 1 (true) for retrograde
42
+ fullDegree: real('full_degree'), // Full degree in 360° system
43
+ normDegree: real('norm_degree'), // Degree within the sign (0-29°)
44
+ speed: real('speed'), // Speed of the planet
45
+ isRetro: integer('is_retro'), // 0 (false) or 1 (true) for retrograde
44
46
  },
45
47
  (t) => [index('astrological_data_user_id_idx').on(t.userId)]
46
48
  );
@@ -48,7 +50,8 @@ export const astrologicalData = sqliteTable(
48
50
  export const products = sqliteTable(
49
51
  'products',
50
52
  {
51
- id: text('id').primaryKey(),
53
+ id: text('id')
54
+ .primaryKey(),
52
55
  name: text('name').unique().notNull(),
53
56
  description: text('description'),
54
57
  createdAt: text('created_at')
@@ -61,7 +64,8 @@ export const products = sqliteTable(
61
64
  export const generations = sqliteTable(
62
65
  'generations',
63
66
  {
64
- id: text('id').primaryKey(),
67
+ id: text('id')
68
+ .primaryKey(),
65
69
  userId: text('user_id')
66
70
  .notNull()
67
71
  .references(() => users.id, { onDelete: 'cascade' }),
@@ -86,12 +90,13 @@ export const generations = sqliteTable(
86
90
  export const tokens = sqliteTable(
87
91
  'tokens',
88
92
  {
89
- id: text('id').primaryKey(),
93
+ id: text('id')
94
+ .primaryKey(),
90
95
  userId: text('user_id')
91
96
  .notNull()
92
97
  .references(() => users.id, { onDelete: 'cascade' }),
93
98
  refreshToken: text('refresh_token').unique().notNull(),
94
- expiresAt: text('expires_at').notNull(), // Expiration timestamp for the token
99
+ expiresAt: text('expires_at').notNull(),
95
100
  createdAt: text('created_at')
96
101
  .default(sql`CURRENT_TIMESTAMP`)
97
102
  .notNull(),
package/drizzle.config.ts CHANGED
@@ -5,4 +5,5 @@ export default defineConfig({
5
5
  out: './db/migrations', // Path to store generated migrations
6
6
  dialect: 'sqlite',
7
7
  driver: 'd1-http', // Use "sqlite" for D1 Database
8
+ casing: 'snake_case',
8
9
  });
@@ -5,28 +5,34 @@ import { verifyToken } from '../utils';
5
5
  export const jwtMiddleware = async (c: AuthCtx, next: () => Promise<void>) => {
6
6
  let token: string | undefined = undefined;
7
7
 
8
- // Check for the Authorization header
9
8
  const authHeader = c.req.header('Authorization');
10
9
  if (authHeader && authHeader.startsWith('Bearer ')) {
11
- token = authHeader.substring(7); // Remove 'Bearer ' prefix
10
+ token = authHeader.substring(7);
11
+ console.log('Token extracted from Authorization header:', token);
12
12
  }
13
13
 
14
14
  if (!token) {
15
- token = getCookie(c, 'accessToken');
15
+ token = getCookie(c, 'authToken');
16
+ if (token) {
17
+ console.log('Token extracted from cookie:', token);
18
+ }
16
19
  }
17
20
 
18
21
  if (!token) {
22
+ console.warn('Unauthorized: No token provided');
19
23
  return c.json({ error: 'Unauthorized: No token provided' }, 401);
20
24
  }
21
25
 
22
26
  try {
27
+ console.log('Verifying token...');
23
28
  const payload = await verifyToken(c, token);
24
29
 
30
+ console.log('Token verified successfully. Payload:', payload);
25
31
  c.set('jwtPayload', payload);
26
32
 
27
33
  await next(); // Proceed to the next middleware or route handler
28
34
  } catch (err: any) {
29
- console.error(err.message);
35
+ console.error('Token verification failed:', err.message);
30
36
  return c.json({ error: 'Unauthorized: Invalid or expired token' }, 401);
31
37
  }
32
- };
38
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -8,7 +8,9 @@
8
8
  },
9
9
  "scripts": {
10
10
  "migrate-latest-test": "wrangler d1 execute DB --file=$(ls -t ./db/migrations/*.sql | head -n 1)",
11
- "migrate-latest": "wrangler d1 execute DB --file=$(ls -t ./db/migrations/*.sql | head -n 1) --remote"
11
+ "migrate-latest": "wrangler d1 execute DB --file=$(ls -t ./db/migrations/*.sql | head -n 1) --remote",
12
+ "db:generate": "drizzle-kit generate",
13
+ "db:up": "drizzle-kit up"
12
14
  },
13
15
  "devDependencies": {
14
16
  "bun-types": "latest"