Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
55665a4
added endpoints/controllers for elo handling, added database config file
nsmzoneli May 17, 2026
d4880e4
added: user unit tests
MbathaN May 12, 2026
c340ac9
fixed: minor depency issues for .ts test code
MbathaN May 15, 2026
7a9da58
removed: unecessary docker backend files
MbathaN May 15, 2026
d33e0db
added endpoints/controllers for elo handling, added database config file
nsmzoneli May 17, 2026
0768cb8
added most of the endpoints for matches, cleaned up init.sql a bit
nsmzoneli May 17, 2026
c8710b1
added controller for match logging
nsmzoneli May 17, 2026
15b6a61
added routes for the matches controllers
nsmzoneli May 17, 2026
e729222
attend to added comment about addressing important feature
nsmzoneli May 18, 2026
16173e4
added: user unit tests
MbathaN May 12, 2026
fc8db77
fixed: minor depency issues for .ts test code
MbathaN May 15, 2026
38cfb86
added root README content, fixed small typo in api
nsmzoneli May 14, 2026
01157e4
added endpoints/controllers for elo handling, added database config file
nsmzoneli May 17, 2026
0b820b1
added: user unit tests
MbathaN May 12, 2026
485a0a3
fixed: minor depency issues for .ts test code
MbathaN May 15, 2026
7480a0e
re-ran npm install to fix dependency issues
nsmzoneli May 18, 2026
2a54297
delete: elo.routes, already in api.routes
nsmzoneli May 18, 2026
c1596b2
Added mathfield component for frontend use
nsmzoneli May 18, 2026
aa89595
added code for the virtual on screen math symbols keyboard
nsmzoneli May 18, 2026
4da7ab5
added: testing page for the keyboard and mathfields, added app routin…
nsmzoneli May 18, 2026
1f4c15c
added: textbox element for the keyboard to be used
nsmzoneli May 18, 2026
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
18 changes: 18 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
node_modules
npm-debug.log
.git
.gitignore
README.md
.env
.env.local
.env.*.local
dist
build
.vscode
.idea
*.swp
*.swo
*~
.DS_Store
coverage
.nyc_output
36 changes: 31 additions & 5 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
FROM node:18-alpine
# Build stage
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci

# Production stage
FROM node:18-alpine
WORKDIR /app

COPY package*.json ./
RUN npm install
# Install dumb-init for proper signal handling
RUN apk add --no-cache dumb-init

COPY . .
# Create non-root user
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001

# Copy only production dependencies from builder
COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
COPY --chown=nodejs:nodejs package*.json ./

# Copy application code
COPY --chown=nodejs:nodejs . .

# Remove dev dependencies in production
RUN npm prune --production

# Switch to non-root user
USER nodejs

EXPOSE 3000

CMD ["node", "src/server.js"]
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"

# Use dumb-init to handle signals properly
ENTRYPOINT ["dumb-init", "--"]
CMD ["npm", "start"]
35 changes: 24 additions & 11 deletions backend/package-lock.json

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

11 changes: 10 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,24 @@
"^.+\\.ts$": ["ts-jest", { "tsconfig": "tsconfig.test.json" }]
}
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"transform": {
"^.+\\.ts$": ["ts-jest", { "tsconfig": "tsconfig.test.json" }]
}
},
"devDependencies": {
"@types/cors": "^2.8.19",
"@types/express": "^5.0.6",
"@types/jest": "^30.0.0",
"@types/jest": "^30.0.0",
"@types/node": "^25.7.0",
"@types/supertest": "^7.2.0",
"supertest": "^7.1.0",
"ts-jest": "^29.4.9",
"ts-node": "^10.9.2",
"typescript": "^6.0.3"
"typescript": "^6.0.3",
"supertest": "^7.2.2"
}
}
3 changes: 3 additions & 0 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import express, { Request, Response } from 'express'
import cors from 'cors'
import eloRoutes from './routes/elo.routes';

const app = express();
app.disable('x-powered-by'); //so express version isn't included in responses

app.use(cors({origin: process.env.FRONTEND_URL || 'http://localhost:5173'}));
app.use(express.json());
app.use('/api/elo', eloRoutes);
app.use('/api/elo', eloRoutes);

app.get('/health', (req: Request, res: Response) => {
res.json({ status: 'ok'});
Expand Down
19 changes: 19 additions & 0 deletions backend/src/config/db.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Pool } from 'pg';
import dotenv from 'dotenv';

dotenv.config();

const pool = new Pool({
connectionString: process.env.DATABASE_URL
});

pool.on('connect', () => {
console.log('Connected to the database');
});

pool.on('error', (err) => {
console.error('Unexpected error on idle client', err);
process.exit(-1);
});

export default pool;
Loading
Loading