Gal Podlipnik 4526870b2a docks
2025-07-14 22:20:46 +02:00

95 lines
2.0 KiB
Markdown

# Server Setup and Run Instructions
This is a Node.js server built with Hono framework, using SQLite database with Drizzle ORM.
## Prerequisites
- Node.js (version 18 or higher)
- npm or yarn package manager
## Initial Setup
### 1. Install Dependencies
```bash
cd server
npm install
```
### 2. Environment Configuration
The server uses a `.env` file for configuration. The current setup uses:
```bash
DB_FILE_NAME=file:./src/db/local.db
```
This is already configured and will create a local SQLite database file.
### 3. Database Setup
#### Generate Database Schema
```bash
npm run db:generate
```
#### Push Schema to Database
```bash
npm run db:push
```
#### Seed Database with Sample Data
```bash
npm run db:seed
```
This will create sample users, tasks, and comments using faker.js.
## Available Scripts
- `npm run dev` - Start development server with hot reload
- `npm run db:push` - Push schema changes to database
- `npm run db:generate` - Generate database migrations
- `npm run db:migrate` - Run database migrations
- `npm run db:reset` - Reset database (careful - this will delete all data)
- `npm run db:seed` - Seed database with sample data
## Running the Server
### Development Mode
```bash
npm run dev
```
The server will start on `http://localhost:3000`
## API Endpoints
The server provides the following API routes:
- `/users` - User management endpoints
- `/tasks` - Task management endpoints
- `/comments` - Comment management endpoints
## Database
The server uses SQLite with Drizzle ORM. The database file is stored at `./src/db/local.db` and will be created automatically when you run the setup commands.
## Technology Stack
- **Framework**: Hono.js
- **Database**: SQLite
- **ORM**: Drizzle ORM
- **Runtime**: Node.js
- **Development**: tsx for TypeScript execution
## Troubleshooting
1. **Database issues**: Run `npm run db:reset` and then `npm run db:push` followed by `npm run db:seed`
2. **Port conflicts**: The server runs on port 3000 by default
3. **Dependencies**: Make sure all dependencies are installed with `npm install`