Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekitech committed Apr 7, 2024
1 parent 834e4a9 commit d28cdd6
Show file tree
Hide file tree
Showing 18 changed files with 412 additions and 60 deletions.
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
doc_back_build:
docker_build_backend:
docker-compose up -d --build reeq-backend --wait
watch:
docker compose watch
docker_build:
docker-compose up -d --build --wait

docker_create_volume:
docker volume create db_volume

build: docker_create_volume docker_build run_db_push

run_db_push:
npx prisma db push

run_migrations:
npx prisma migrate deploy
## Для загрузки дампа
## заходим в контейнер базы и пишем
# pg_dump <name_db> -U <name_user> < reeq-db.dump
#




# Windows
prisma_add_migrate :
docker-compose exec reeq-backend sh -c 'npx prisma migrate dev --name %migration_name%'
Expand Down
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ services:
ports:
- "${DB_EXTERNAL_PORT}:${DB_PORT}"
environment:
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_USER=${DB_USER}
- POSTGRES_DB=${DB_NAME}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_USER=${DB_USER}
- POSTGRES_DB=${DB_NAME}
networks:
- reeq-network
reeq-backend:
Expand All @@ -31,6 +31,8 @@ services:
- action: rebuild
path: ./prisma
target: /usr/src/reeq-backend/prisma
- action: rebuild
path: .env
build:
context: ./
dockerfile: docker/Dockerfile
Expand Down
6 changes: 0 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@ RUN npm ci
#prisma init
RUN npx prisma generate

ENV DATABASE_URL="postgresql://postgres:postgres@db:5437/reeq-db?schema=public"

## Push prisma schema to database
#RUN npx prisma db push

# Copy folder project
COPY . .

## Build
#RUN npm run build

EXPOSE 3005

CMD ["npm", "run", "dev"]
201 changes: 199 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"express-validator": "^7.0.1",
"jsonwebtoken": "^9.0.2",
"module-alias": "^2.2.3",
"moment": "^2.30.1",
"multer": "^1.4.5-lts.1",
"pg": "^8.11.3"
"pg": "^8.11.3",
"socket.io": "^4.7.5"
}
}
13 changes: 13 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import {bookingRoutes} from "./infrastructure/routes/rest/BookingRoutes";
import {uploadRoutes} from "./infrastructure/routes/rest/UploadRoutes";
import bodyParser from "body-parser";
import multer from "multer";
import {Server} from "socket.io";
import * as http from "node:http";

dotenv.config();
const app = express();
const router = express.Router();
const server = new http.Server(app)

app.use(express.json())
app.use(cookieParser())
app.use(multer().any());
Expand All @@ -42,6 +46,15 @@ app.use("/api", router)
app.use(ErrorMiddleware)

const port = process.env.PORT;

// Websocket init

const io = new Server(server)
io.on('connection', (socket) => {
console.log('a user connected');
});


app.get('/api', (req, res) => {
res.send('Express + TypeScript Server');
});
Expand Down
5 changes: 3 additions & 2 deletions src/app/repositories/BookingRepo.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {Booking} from "../models/Booking/Booking";
import {addBookingDto} from "./dto/addBookingDto";
import {addBookingDto, getBookingByParamsDtoType} from "./dto/addBookingDto";
import {updateBookingDto} from "./dto/updateBookingDto";

export interface BookingRepo {
getById(id: number): Promise<Booking[] | null>
getByFilter(date: string, skip: number| undefined, take: number| undefined): Promise<Booking[] | null>
add(booking: addBookingDto): Promise<Booking>
update(booking: updateBookingDto): Promise<Omit<Booking, "equipments">>
getByField(fields: object): Promise<{}[]>
getByParams(params: getBookingByParamsDtoType, include: object): any
getListsTimeReservation(equipment_id: number): any
}
Loading

0 comments on commit d28cdd6

Please sign in to comment.