Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

persistence ok and zod on db entity #9

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
docker*
docker-compose.yml

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# node-rps-andrea

node tutorial steps
6 changes: 0 additions & 6 deletions app.ts

This file was deleted.

20 changes: 20 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: "3.7"
services:
postgres:
image: postgres:12.1-alpine
environment:
- POSTGRES_USER=root
- POSTGRES_PASSWORD=root
- POSTGRES_DB=root
logging:
options:
max-size: 10m
max-file: "3"
ports:
- "5438:5432"
volumes:
- local_test_andrea:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql

volumes:
local_test_andrea:
5 changes: 5 additions & 0 deletions docker/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
create table Results (
id SERIAL PRIMARY KEY,
result varchar NOT NULL,
game_date timestamp NOT NULL DEFAULT now()
);
21 changes: 0 additions & 21 deletions game.test.ts

This file was deleted.

41 changes: 0 additions & 41 deletions game.ts

This file was deleted.

2 changes: 2 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { app } from "./routes/api";
app.listen(3000);
14 changes: 7 additions & 7 deletions model/result.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { z } from "zod";

export enum Result {
WIN = "You Win!!!",
LOSE = "You lose :< ",
DRAW = "It's a Draw!",
}
export const result = z.object({
game_date: z.coerce.date(),
result: z.enum(["WIN", "LOSE", "DRAW"]),
});

const ResultEnum = z.nativeEnum(Result);
export type ResultEnum = z.infer<typeof ResultEnum>;
export type Result = z.infer<typeof result>;
export const resultArray = z.array(result);
export type ResultArray = z.infer<typeof resultArray>;
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"@zodios/core": "^10.9.6",
"@zodios/express": "^10.6.1",
"axios": "^1.5.0",
"express": "^4.18.2",
"pg-promise": "^11.5.4",
"ts-pattern": "^5.0.5",
"zod": "^3.22.2"
}
Expand Down
138 changes: 138 additions & 0 deletions pnpm-lock.yaml

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

Loading