some shit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
[logiflow]
|
||||
logLevel = 1
|
||||
|
||||
[database]
|
||||
host = "postgres"
|
||||
port = 5432
|
||||
sslmode = "disable"
|
||||
|
||||
[server]
|
||||
host = "0.0.0.0"
|
||||
port = 3001
|
||||
readTimeout = "10s"
|
||||
writeTimeout = "30s"
|
||||
idleTimeout = "60s"
|
||||
|
||||
[redis]
|
||||
addr = "redis:6379"
|
||||
db = 0
|
||||
refreshTokenTTL = "168h"
|
||||
accessTokenTTL = "24h"
|
||||
|
||||
[jwt]
|
||||
issuer = "logiflow-server"
|
||||
audience = "logiflow-client"
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package: api
|
||||
generate:
|
||||
chi-server: true
|
||||
models: true
|
||||
output: internal/api/gen.go
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: logiflow
|
||||
description: API для информационной системы для логистической компании
|
||||
version: 1.0.0
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
package database
|
||||
|
||||
import "github.com/jackc/pgx/v5/pgxpool"
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
|
||||
func NewConnectionPool(connectionString string) (*pgxpool.Pool, error)
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
func NewConnectionPool(ctx context.Context, connectionString string) (*pgxpool.Pool, error) {
|
||||
pool, err := pgxpool.New(ctx, connectionString)
|
||||
if err != nil {
|
||||
slog.ErrorContext(ctx, "Cant create pool of connection", slog.String("Error", err.Error()))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := pool.Ping(ctx); err != nil {
|
||||
slog.ErrorContext(ctx, "Cant ping connection", slog.String("Error", err.Error()))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return pool, nil
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/anxi0uz/logiflow/internal/config"
|
||||
"github.com/redis/go-redis"
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
@@ -16,7 +15,7 @@ func NewRedisConnection(ctx context.Context, cfg *config.Config) (*redis.Client,
|
||||
DB: cfg.Redis.DB,
|
||||
})
|
||||
|
||||
_, err := rdb.Ping().Result()
|
||||
_, err := rdb.Ping(ctx).Result()
|
||||
if err != nil {
|
||||
slog.ErrorContext(ctx, "Cant ping redis", slog.String("Error", err.Error()))
|
||||
return nil, err
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
SELECT 'up SQL query';
|
||||
CREATE EXTENSION IF NOT EXISTS pg_tgrm;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
SELECT 'down SQL query';
|
||||
DROP EXTENSION IF EXISTS pg_tgrm;
|
||||
-- +goose StatementEnd
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
SELECT 'up SQL query';
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
slug VARCHAR(120) UNIQUE NOT NULL,
|
||||
password_hash VARCHAR(255) NOT NULL,
|
||||
full_name VARCHAR(150),
|
||||
avatar_url VARCHAR(512),
|
||||
role VARCHAR(50) DEFAULT 'student',
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ,
|
||||
last_login_at TIMESTAMPTZ
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
SELECT 'down SQL query';
|
||||
DROP TABLE IF EXISTS users;
|
||||
-- +goose StatementEnd
|
||||
|
||||
Reference in New Issue
Block a user