Skip to content

Commit

Permalink
windows succes and bad request
Browse files Browse the repository at this point in the history
  • Loading branch information
Prrromanssss committed Feb 18, 2024
1 parent 04ded20 commit 2a4b75b
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 14 deletions.
24 changes: 24 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Ignore Go temporary files
**/*.test
**/*_test.go
**/*_test

# Ignore TypeScript temporary files
**/*.js
**/*.map
**/*.d.ts

# Ignore temporary files for npm и yarn
node_modules/

# Ignore dependencies files for go
vendor/

# Ignore files, created by VS Code
.vscode

# Ignore local temporary files
.DS_Store

# Ignore files for CI/CD
.github
8 changes: 5 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
PORT=YOUR-SITE-PORT
DB_URL=YOUR-DB-CONNECTION-URL
RABBIT_MQ_URL=YOUR-RABBITMQ-CONNECTION-URL
DB_URL=postgres://YOUR-LOGIN:YOUR-PASSWORD@localhost:5432/YOUR-DATABASE?sslmode=disable
RABBIT_MQ_URL=amqp://guest:guest@localhost:5672/
POSTGRES_USER=YOUR-POSTGRES-USER
POSTGRES_PASSWORD=YOUR-POSTGRES-PASSWORD
POSTGRES_DB=YOUR-POSTGRES-DATABASE
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
vendor/

# Go workspace file
go.work
Expand Down
29 changes: 29 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM golang:1.21.1 AS builder

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

RUN go get -u github.com/pressly/goose/cmd/goose

COPY . .

RUN go build -o daee .

FROM debian:buster

COPY --from=builder /app/daee /usr/local/bin/daee

EXPOSE 3000

COPY .env /

RUN bash -c 'source /.env'

COPY sql/schema /app/sql/schema

RUN cd /app/sql/schema && goose postgres postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB} up

CMD ["daee"]
Binary file modified backend/cmd/daee/main
Binary file not shown.
10 changes: 2 additions & 8 deletions backend/cmd/daee/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ func main() {
// Load env variables
godotenv.Load(fmt.Sprintf("%s/.env", filepath.Dir(rootPath)))

portString := os.Getenv("PORT")

if portString == "" {
log.Fatal("PORT is not found in environment")
}

// Configuration database
dbURL := os.Getenv("DB_URL")

Expand Down Expand Up @@ -158,10 +152,10 @@ func main() {

srv := &http.Server{
Handler: router,
Addr: ":" + portString,
Addr: ":3000",
}

log.Printf("Server starting on port %v", portString)
log.Printf("Server starting on port %v", 3000)
err = srv.ListenAndServe()
if err != nil {
log.Fatal(err)
Expand Down
34 changes: 34 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3'

services:
postgres:
image: postgres:latest
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "5432:5432"

rabbitmq:
image: rabbitmq:latest
ports:
- "5672:5672"
- "15672:15672"

frontend:
build:
context: ./frontend
dockerfile: Dockerfile
ports:
- "3000:3000"

backend:
build:
context: ./backend
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
DB_URL: ${DB_URL}
RABBIT_MQ_URL: ${RABBIT_MQ_URL}
23 changes: 22 additions & 1 deletion frontend/package-lock.json

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

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"dependencies": {
"axios": "^1.6.7",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-toastify": "^10.0.4"
},
"devDependencies": {
"@types/react": "^18.2.55",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
<ToastContainer />
</React.StrictMode>,
)
5 changes: 5 additions & 0 deletions frontend/src/pages/Expressions/ExpressionsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Button } from "src/components/Button/Button";
import { Input } from "src/components/Input/Input";
import { createExpression, getExpressions } from "src/services/api";
import { ExpressionBlock } from "src/components/ExpressionBlock/ExpressionBlock";
import { toast } from 'react-toastify';

export const ExpressionsPage = () => {
const [expressions, setExpressions] = useState<Expression[]>([]);
Expand All @@ -13,9 +14,13 @@ export const ExpressionsPage = () => {
const createHandler = () => {
createExpression(newExpression)
.then(() => {
toast.success("Success");
getExpressions()
.then(data => setExpressions(data));
})
.catch((err) => {
toast.error(err.response.data.error);
})
.finally(() => {
setNewExpression("");
});
Expand Down

0 comments on commit 2a4b75b

Please sign in to comment.