Skip to content

Commit

Permalink
Merge pull request #4 from targoninc/alex
Browse files Browse the repository at this point in the history
Merge a bunch of changes
  • Loading branch information
loudar authored May 27, 2024
2 parents d8e0f83 + c43a9fd commit 95b436e
Show file tree
Hide file tree
Showing 22 changed files with 1,566 additions and 196 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Docker Image

on:
push:
branches: [main]
workflow_dispatch:

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]

- name: Log in to Docker registry
uses: docker/[email protected]
with:
registry: ${{ secrets.REGISTRY_HOST }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}

- name: Generate image name
id: reponame
uses: ashley-taylor/[email protected]
with:
value: ${{ github.repository }}
regex: /|-|_
flags: g
replacement: _

- name: Show image name
run: echo "${{ steps.reponame.outputs.value }}"

- name: Build and tag Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: false
tags: ${{ secrets.REGISTRY_HOST }}/${{ steps.reponame.outputs.value }}:latest, ${{ secrets.REGISTRY_HOST }}/${{ steps.reponame.outputs.value }}:${{ github.run_number }}

- name: Push Docker image to registry
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: true
tags: ${{ secrets.REGISTRY_HOST }}/${{ steps.reponame.outputs.value }}:latest, ${{ secrets.REGISTRY_HOST }}/${{ steps.reponame.outputs.value }}:${{ github.run_number }}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN npm run build:main

# Make the app's ports available to the outside world
EXPOSE 3000
EXPOSE 8912

# Define the command to run the app
CMD ["npm", "run", "start"]
28 changes: 28 additions & 0 deletions docker-compose-built.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: '3'

services:
app:
container_name: app
image: ${DOCKER_IMAGE_APP}
restart: always
ports:
- "3000:3000"
- "8912:8912"
depends_on:
- db
env_file:
- .env

db:
container_name: mariadb
image: mariadb:10.5
restart: always
ports:
- "3306:3306"
env_file:
- .env
volumes:
- db_data:/var/lib/mysql

volumes:
db_data:
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ services:
build:
context: .
dockerfile: Dockerfile
restart: always
ports:
- "3000:3000"
- "8912:8912"
depends_on:
- db
env_file:
Expand All @@ -16,6 +18,7 @@ services:
db:
container_name: mariadb
image: mariadb:10.5
restart: always
ports:
- "3306:3306"
env_file:
Expand Down
67 changes: 66 additions & 1 deletion package-lock.json

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

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,31 @@
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"express-session": "^1.18.0",
"mariadb": "^3.3.0",
"passport": "^0.7.0",
"passport-local": "^1.0.0",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.0"
"swagger-ui-express": "^5.0.0",
"ws": "^8.17.0"
},
"devDependencies": {
"@babel/cli": "^7.24.5",
"@babel/preset-env": "^7.24.5",
"@babel/preset-typescript": "^7.24.1",
"@rmp135/sql-ts": "^2.1.0",
"@types/bcryptjs": "^2.4.6",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/express-session": "^1.18.0",
"@types/passport": "^1.0.16",
"@types/passport-local": "^1.0.38",
"@types/swagger-jsdoc": "^6.0.4",
"@types/swagger-ui-express": "^4.1.6",
"@types/ws": "^8.5.10",
"babel-plugin-add-import-extension": "^1.6.0",
"babel-watch": "^7.8.1",
"mysql2": "^3.9.7",
Expand Down
8 changes: 8 additions & 0 deletions src/enums/permissionsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,12 @@ export const PermissionsList: Record<string, Permission> = {
name: "getUserPermissions",
description: "Can get the permissions of another user."
},
deleteMessage: {
name: "deleteMessage",
description: "Can delete a message."
},
deleteChannel: {
name: "deleteChannel",
description: "Can delete a channel."
},
}
17 changes: 13 additions & 4 deletions src/featureManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@ import {AuthenticationFeature} from "./features/authenticationFeature";
import {DatabaseFeature} from "./features/databaseFeature";
import {CLI} from "./tooling/CLI";
import {MessagingFeature} from "./features/messagingFeature";
import {Application} from "express";
import path from "path";
import express, {Application} from "express";
import swaggerJsDoc from "swagger-jsdoc";
import {swaggerOptions} from "./swagger";
import swaggerUI from "swagger-ui-express";
import cors from "cors";
import {LiveFeature} from "./features/liveFeature";
import {User} from "./features/database/models";

export class FeatureManager {
static async enable(__dirname: string) {
const db = await DatabaseFeature.enable(__dirname);
const app = AuthenticationFeature.enable(__dirname, db);
MessagingFeature.enable(app);
const app = express();
app.use(cors({
origin: process.env.UI_DEPLOYMENT_URL ?? 'http://localhost:3001',
credentials: true
}));
const userMap = new Map<string, User>();
AuthenticationFeature.enable(__dirname, app, db, userMap);
MessagingFeature.enable(app, db);
LiveFeature.enable(app, userMap, db);

FeatureManager.addSwagger(__dirname, app);

Expand Down
2 changes: 1 addition & 1 deletion src/features/authentication/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class AuthActions {
req.requestId = Math.random().toString(36).substring(7);
return next();
}
res.send({error: "Not authenticated"});
res.status(401).send({error: "Not authenticated"});
}
}

Expand Down
Loading

0 comments on commit 95b436e

Please sign in to comment.