Initial commit: add .gitignore and README
This commit is contained in:
25
packages/shared-types/package.json
Normal file
25
packages/shared-types/package.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@workspace/shared-types",
|
||||
"version": "1.0.0",
|
||||
"description": "Common TypeScript types and interfaces",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"test": "vitest",
|
||||
"lint": "eslint src",
|
||||
"type-check": "tsc --noEmit",
|
||||
"clean": "rm -rf dist"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.5.4",
|
||||
"vitest": "^1.2.0"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "restricted"
|
||||
}
|
||||
}
|
||||
|
||||
29
packages/shared-types/src/api.ts
Normal file
29
packages/shared-types/src/api.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* API-related types
|
||||
*/
|
||||
|
||||
export interface PaginationParams {
|
||||
page: number;
|
||||
limit: number;
|
||||
offset?: number;
|
||||
}
|
||||
|
||||
export interface PaginatedResponse<T> {
|
||||
data: T[];
|
||||
pagination: {
|
||||
page: number;
|
||||
limit: number;
|
||||
total: number;
|
||||
totalPages: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface SortParams {
|
||||
field: string;
|
||||
order: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
export interface FilterParams {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
33
packages/shared-types/src/config.ts
Normal file
33
packages/shared-types/src/config.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Configuration-related types
|
||||
*/
|
||||
|
||||
export interface DatabaseConfig {
|
||||
host: string;
|
||||
port: number;
|
||||
database: string;
|
||||
username: string;
|
||||
password: string;
|
||||
ssl?: boolean;
|
||||
pool?: {
|
||||
min?: number;
|
||||
max?: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ServerConfig {
|
||||
port: number;
|
||||
host: string;
|
||||
env: 'development' | 'staging' | 'production';
|
||||
cors?: {
|
||||
origin: string | string[];
|
||||
credentials?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface LoggingConfig {
|
||||
level: 'debug' | 'info' | 'warn' | 'error';
|
||||
format: 'json' | 'text';
|
||||
destination?: string;
|
||||
}
|
||||
|
||||
20
packages/shared-types/src/database.ts
Normal file
20
packages/shared-types/src/database.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Database-related types
|
||||
*/
|
||||
|
||||
export interface BaseEntity {
|
||||
id: string;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
deletedAt?: Date | null;
|
||||
}
|
||||
|
||||
export interface SoftDeletable {
|
||||
deletedAt: Date | null;
|
||||
}
|
||||
|
||||
export interface Timestamped {
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
54
packages/shared-types/src/index.ts
Normal file
54
packages/shared-types/src/index.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @workspace/shared-types
|
||||
* Common TypeScript types and interfaces
|
||||
*/
|
||||
|
||||
// API Response Types
|
||||
export interface ApiResponse<T> {
|
||||
data: T;
|
||||
status: number;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface ApiError {
|
||||
code: string;
|
||||
message: string;
|
||||
details?: unknown;
|
||||
}
|
||||
|
||||
// Database Types
|
||||
export interface BaseEntity {
|
||||
id: string;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
// Configuration Types
|
||||
export interface DatabaseConfig {
|
||||
host: string;
|
||||
port: number;
|
||||
database: string;
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface ServerConfig {
|
||||
port: number;
|
||||
host: string;
|
||||
env: 'development' | 'staging' | 'production';
|
||||
}
|
||||
|
||||
// Common Utility Types
|
||||
export type Nullable<T> = T | null;
|
||||
export type Optional<T> = T | undefined;
|
||||
export type Maybe<T> = T | null | undefined;
|
||||
|
||||
// Status Types
|
||||
export type Status = 'active' | 'inactive' | 'pending' | 'archived';
|
||||
export type Priority = 'low' | 'medium' | 'high' | 'critical';
|
||||
|
||||
// Export all types
|
||||
export * from './api';
|
||||
export * from './database';
|
||||
export * from './config';
|
||||
|
||||
20
packages/shared-types/tsconfig.json
Normal file
20
packages/shared-types/tsconfig.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2022"],
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user