Skip to content

Commit

Permalink
Merge pull request #6 from isd-sgcu/feat/api
Browse files Browse the repository at this point in the history
Feat/api
  • Loading branch information
ImSoZRious authored Mar 28, 2024
2 parents 5fbf312 + b9a77ce commit b3a8f0a
Show file tree
Hide file tree
Showing 35 changed files with 3,792 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/server/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM mcr.microsoft.com/devcontainers/javascript-node:1-20-bullseye

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment if you want to install an additional version of node using nvm
# ARG EXTRA_NODE_VERSION=10
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"

# [Optional] Uncomment if you want to install more global node modules
# RUN su node -c "npm install -g <your-package-list-here>"
15 changes: 15 additions & 0 deletions apps/server/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "CU-TU Unity 2024",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"customizations": {
"vscode": {
"extensions": [
"loiane.ts-extension-pack",
"ms-azuretools.vscode-docker",
"tamasfe.even-better-toml"
]
}
}
}
31 changes: 31 additions & 0 deletions apps/server/.devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3.8'

services:
app:
build:
context: .
dockerfile: Dockerfile

volumes:
- ../..:/workspaces:cached

command: sleep infinity

db:
image: postgres:latest
restart: unless-stopped
volumes:
- ./postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres

redis:
image: redis:latest
restart: unless-stopped
volumes:
- ./redis-data:/data

volumes:
postgres-data:
4 changes: 4 additions & 0 deletions apps/server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.env
.env.sample
.devcontainer
node_modules
7 changes: 7 additions & 0 deletions apps/server/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BASIC_AUTH="Basic YWRtaW46cGFzc3dvcmQ="

DB_HOST=127.0.0.1
DB_NAME=cutu
DB_USER=postgres
DB_PASSWORD=postgres
DB_PORT=5432
14 changes: 14 additions & 0 deletions apps/server/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# @format

# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: 'devcontainers'
directory: '/'
schedule:
interval: weekly
6 changes: 6 additions & 0 deletions apps/server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist/
node_modules/
.devcontainer/postgres-data/
.devcontainer/redis-data/
.env*
!.env.sample
4 changes: 4 additions & 0 deletions apps/server/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.devcontainer/postgres-data
.devcontainer/redis-data
dist/
node_modules/
9 changes: 9 additions & 0 deletions apps/server/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"arrowParens": "always",
"bracketSameLine": true,
"semi": false,
"endOfLine": "lf",
"quoteProps": "as-needed",
"singleQuote": true,
"insertPragma": false
}
23 changes: 23 additions & 0 deletions apps/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:20.12.0-alpine3.19 AS builder

WORKDIR /build

COPY package*.json ./

RUN npm install

COPY . ./

RUN npm run build

FROM node:20.12.0-alpine3.19 AS runner

WORKDIR /app

COPY --from=builder /build/dist/ ./dist/
COPY package*.json ./
RUN npm install --omit=dev

EXPOSE 3000

CMD [ "npm", "start" ]
25 changes: 25 additions & 0 deletions apps/server/migrations/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
CREATE TABLE IF NOT EXISTS games (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
title varchar(255) NOT NULL,
description text NOT NULL DEFAULT '',
image varchar(255) NOT NULL DEFAULT '',
open boolean NOT NULL DEFAULT false,
actions jsonb NOT NULL DEFAULT '[]',
winner jsonb NOT NULL DEFAULT '{}'
);

CREATE TABLE IF NOT EXISTS players (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
sid uuid NOT NULL,
name varchar(255) NOT NULL,
total_score integer NOT NULL DEFAULT 0
);

CREATE TABLE IF NOT EXISTS game_history (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
game_id uuid NOT NULL,
player_id uuid NOT NULL,
action jsonb NOT NULL,
created_at timestamp NOT NULL DEFAULT now()
);

Loading

0 comments on commit b3a8f0a

Please sign in to comment.