Skip to content

Commit e842048

Browse files
committed
chore(shared): add shared package README and environment example
- Add comprehensive README for shared package - Add .env.example for database configuration - Add index.ts exports for shared modules - Add pnpm-lock.yaml for dependency locking Completes shared package documentation and configuration.
1 parent 4ab2e2f commit e842048

File tree

8 files changed

+5855
-0
lines changed

8 files changed

+5855
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Route exports
3+
*/
4+
5+
export { healthRouter } from './health';
6+
export { createIdentityRouter } from './identity';
7+

packages/shared/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Database
2+
DATABASE_URL="postgresql://battlepass:password@localhost:5432/battlepass?schema=public"

packages/shared/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# @battlepass/shared
2+
3+
Shared types, events, utilities, and database client for the Battlepass system.
4+
5+
## Usage
6+
7+
### Types
8+
```typescript
9+
import { Identity, Platform, Quest, Source, ActivityType } from '@battlepass/shared';
10+
```
11+
12+
### Events
13+
```typescript
14+
import { IdentityCreatedEvent, QuestCompletedEvent } from '@battlepass/shared';
15+
```
16+
17+
### Database
18+
```typescript
19+
import { prisma } from '@battlepass/shared';
20+
21+
// Use Prisma client
22+
const identity = await prisma.identity.findUnique({
23+
where: { sbtAddress: '0x...' }
24+
});
25+
```
26+
27+
### Utilities
28+
```typescript
29+
import { isValidAddress, formatAddress } from '@battlepass/shared';
30+
```
31+
32+
## Database
33+
34+
### Prisma Setup
35+
36+
1. Set up environment variable:
37+
```bash
38+
DATABASE_URL="postgresql://user:password@localhost:5432/battlepass"
39+
```
40+
41+
2. Generate Prisma Client:
42+
```bash
43+
pnpm db:generate
44+
```
45+
46+
3. Run migrations:
47+
```bash
48+
pnpm db:migrate
49+
```
50+
51+
4. Open Prisma Studio:
52+
```bash
53+
pnpm db:studio
54+
```
55+
56+
## Structure
57+
58+
- `types/` - TypeScript type definitions
59+
- `events/` - Event schemas and types
60+
- `utils/` - Shared utility functions
61+
- `db/` - Prisma client export
62+
- `prisma/` - Prisma schema and migrations

packages/shared/src/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export * from './types';
2+
export * from './events';
3+
export * from './utils';
4+
export * from './db';
5+
export * from './logger';
6+
export * from './rabbitmq';
7+
//# sourceMappingURL=index.d.ts.map

packages/shared/src/index.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/shared/src/index.js

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/shared/src/index.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)