Skip to content

Commit

Permalink
Merge pull request #12 from Joker666/develop
Browse files Browse the repository at this point in the history
Release 1.5
  • Loading branch information
Joker666 authored Mar 2, 2025
2 parents 46546e0 + f2023ae commit 4694d85
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 17 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,29 @@ pnpm install -g typescript
pnpm install -g pino-pretty
```

## Migration
## Run the app

Create a new file `.env` in the root folder and copy contents from the `.env.template` file.

```bash
docker compose up -d
```

### Generate
### Generate db table

```bash
pnpm run db:generate
```

### Migrate
### Migrate schema

```bash
pnpm run db:migrate
```

## Run the app
### Open Swagger UI

```bash
pnpm run dev
open http://localhost:3000/doc
```

Expand Down
6 changes: 3 additions & 3 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'dotenv/config';
import { defineConfig } from 'drizzle-kit';
import env from './src/lib/env.js';
import env from './src/lib/env.ts';

export default defineConfig({
schema: '.src/schema/schema.ts',
out: '.src/schema/migration',
schema: './src/db/schema/schema.ts',
out: './src/db/schema/migration',
dialect: 'mysql',
dbCredentials: {
host: env.DB_HOST,
Expand Down
8 changes: 4 additions & 4 deletions src/lib/database.ts → src/db/database.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Logger as drizzleLogger } from 'drizzle-orm/logger';
import { drizzle } from 'drizzle-orm/mysql2';
import mysql from 'mysql2/promise';
import * as schema from '../schema/schema.js';
import type { userSchema } from '../schema/schema.js';
import env from './env.js';
import { logger } from './logger.js';
import * as schema from './schema/schema.js';
import type { userSchema } from './schema/schema.js';
import env from '../lib/env.js';
import { logger } from '../lib/logger.js';

const DB_ERRORS = {
DUPLICATE_KEY: 'ER_DUP_ENTRY',
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { logger as httpLogger } from 'hono/logger';
import { trimTrailingSlash } from 'hono/trailing-slash';

import { NODE_ENVIRONMENTS } from './lib/constants.js';
import { connection } from './lib/database.js';
import { connection } from './db/database.js';
import { logger } from './lib/logger.js';
import { tracing } from './web/middlelayer/tracing.js';
import { Server } from './web/server.js';
Expand Down
4 changes: 2 additions & 2 deletions src/repository/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { eq } from 'drizzle-orm';
import { userSchema } from '../schema/schema.js';
import { db, type NewUser } from '../lib/database.js';
import { userSchema } from '../db/schema/schema.js';
import { db, type NewUser } from '../db/database.js';

export class UserRepository {
public async create(user: NewUser) {
Expand Down
2 changes: 1 addition & 1 deletion src/web/controller/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Context } from 'hono';
import { DB_ERRORS, type DatabaseError } from '../../lib/database.js';
import { DB_ERRORS, type DatabaseError } from '../../db/database.js';
import { verify } from '../../lib/encryption.js';
import { type JWTPayload, encode } from '../../lib/jwt.js';
import type { UserService } from '../../service/user.js';
Expand Down
2 changes: 1 addition & 1 deletion src/web/controller/serializer/user.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { User } from '../../../lib/database.js';
import type { User } from '../../../db/database.js';

type UserResponse = {
id: number;
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"target": "ESNext",
"module": "nodenext",
"moduleResolution": "nodenext",
"allowImportingTsExtensions": true,
"strict": true,
"skipLibCheck": true,
"types": ["node"],
Expand Down

0 comments on commit 4694d85

Please sign in to comment.