Skip to content

Commit 5bfb19c

Browse files
authored
Merge pull request #2 from Passimx/feat/add-eslint
feat: add all logic
2 parents b50db9d + a76f26d commit 5bfb19c

19 files changed

+4776
-8075
lines changed

.eslintrc.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
project: 'tsconfig.json',
5+
tsconfigRootDir: __dirname,
6+
sourceType: 'module',
7+
},
8+
plugins: ['@typescript-eslint/eslint-plugin', 'import'],
9+
extends: [
10+
'eslint:recommended',
11+
'plugin:@typescript-eslint/recommended',
12+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
13+
'plugin:prettier/recommended',
14+
'plugin:import/warnings',
15+
'plugin:import/errors',
16+
'plugin:import/typescript',
17+
],
18+
settings: {
19+
'import/resolver': {
20+
[require.resolve('eslint-import-resolver-typescript')]: {},
21+
node: {},
22+
},
23+
},
24+
root: true,
25+
env: {
26+
node: true,
27+
jest: true,
28+
es6: true,
29+
},
30+
rules: {
31+
'@typescript-eslint/no-floating-promises': 'off',
32+
'@typescript-eslint/interface-name-prefix': 'off',
33+
'prettier/prettier': 'error',
34+
'@typescript-eslint/ban-ts-comment': 'off',
35+
'@typescript-eslint/no-unsafe-member-access': 'off',
36+
'no-console': 'error',
37+
'keyword-spacing': 'error',
38+
'space-before-blocks': 'error',
39+
'arrow-spacing': 'error',
40+
'key-spacing': 'error',
41+
'switch-colon-spacing': 'error',
42+
'semi-spacing': 'error',
43+
'comma-spacing': 'error',
44+
'func-call-spacing': 'error',
45+
'no-multi-spaces': ['error', { ignoreEOLComments: true }],
46+
'object-curly-spacing': ['error', 'always'],
47+
'@typescript-eslint/no-unused-vars': 'error',
48+
'@typescript-eslint/explicit-function-return-type': 'off',
49+
'@typescript-eslint/explicit-module-boundary-types': 'off',
50+
'@typescript-eslint/no-explicit-any': 'off',
51+
'space-before-function-paren': [
52+
'error',
53+
{
54+
anonymous: 'always',
55+
named: 'never',
56+
asyncArrow: 'always',
57+
},
58+
],
59+
yoda: 'warn',
60+
'import/newline-after-import': 'warn',
61+
'import/no-cycle': 'off',
62+
'import/order': 'warn',
63+
'import/no-named-as-default-member': 'off',
64+
},
65+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- test*
8+
9+
jobs:
10+
build:
11+
uses: Passimx/ci-cd-workflows/.github/workflows/build.yml@main
12+
with:
13+
ORGANIZATION_NAME: ${{ vars.ORGANIZATION_NAME }}
14+
IMAGE_NAME: ${{ vars.IMAGE_NAME }}
15+
secrets:
16+
DOCKER_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
17+
18+
release:
19+
needs: build
20+
uses: Passimx/ci-cd-workflows/.github/workflows/release.yml@main
21+
with:
22+
ORGANIZATION_NAME: ${{ vars.ORGANIZATION_NAME }}
23+
IMAGE_NAME: ${{ vars.IMAGE_NAME }}
24+
secrets:
25+
DOCKER_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
26+
27+
deploy:
28+
needs: release
29+
uses: Passimx/ci-cd-workflows/.github/workflows/deploy.yml@main
30+
secrets:
31+
SSH_USER: ${{ secrets.SSH_USER }}
32+
SSH_HOST: ${{ secrets.SSH_HOST }}
33+
DEPLOY_SCRIPT: ${{ secrets.DEPLOY_SCRIPT }}
34+
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}

.github/workflows/njsscan.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
# This workflow integrates njsscan with GitHub's Code Scanning feature
7+
# nodejsscan is a static security code scanner that finds insecure code patterns in your Node.js applications
8+
9+
name: njsscan sarif
10+
11+
on:
12+
pull_request:
13+
types: [opened, synchronize, reopened]
14+
branches: [ "main" ]
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
njsscan:
21+
permissions:
22+
contents: read # for actions/checkout to fetch code
23+
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
24+
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
25+
runs-on: ubuntu-latest
26+
name: njsscan code scanning
27+
steps:
28+
- name: Checkout the code
29+
uses: actions/checkout@v4
30+
- name: nodejsscan scan
31+
id: njsscan
32+
uses: ajinabraham/njsscan-action@7237412fdd36af517e2745077cedbf9d6900d711
33+
with:
34+
args: '. --sarif --output results.sarif || true'
35+
- name: Upload njsscan report
36+
uses: github/codeql-action/upload-sarif@v3
37+
with:
38+
sarif_file: results.sarif

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npm run build && npm run lint
5+

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"bracketSpacing": true,
5+
"endOfLine": "auto",
6+
"printWidth": 120,
7+
"tabWidth": 4
8+
}

docker-compose.yml

Lines changed: 1 addition & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,11 @@
11
version: '3.8'
22
services:
3-
notifications-service:
4-
image: passimx/notifications-service
5-
container_name: passimx-notifications-service
6-
restart: always
7-
env_file: .env
8-
networks:
9-
- main
10-
depends_on:
11-
- kafka
12-
ports:
13-
- ${APP_PORT_NOTIFICATION}:${APP_PORT_NOTIFICATION}
14-
- ${SOCKET_PORT_NOTIFICATION}:${SOCKET_PORT_NOTIFICATION}
15-
16-
chats-service:
17-
image: passimx/chats-service
18-
container_name: passimx-chats-service
19-
depends_on:
20-
- postgres
21-
- kafka
22-
restart: always
23-
env_file: .env
24-
networks:
25-
- main
26-
ports:
27-
- ${APP_PORT}:${APP_PORT}
28-
29-
postgres:
30-
image: postgres:17-alpine
31-
container_name: passimx-postgres
32-
restart: always
33-
env_file: .env
34-
environment:
35-
POSTGRES_DB: ${PG_DATABASE}
36-
POSTGRES_USER: ${PG_USERNAME}
37-
POSTGRES_PASSWORD: ${PG_PASSWORD}
38-
command: -p ${PG_PORT}
39-
expose:
40-
- ${PG_PORT}
41-
networks:
42-
- main
43-
ports:
44-
- ${PG_PORT}:${PG_PORT}
45-
46-
kafka:
47-
image: 'bitnami/kafka:latest'
48-
container_name: passimx-kafka
49-
restart: always
50-
networks:
51-
- main
52-
env_file: .env
53-
environment:
54-
- KAFKA_ENABLE_KRAFT=yes
55-
- KAFKA_BROKER_ID=1
56-
- KAFKA_CFG_NODE_ID=1
57-
- KAFKA_CFG_PROCESS_ROLES=broker,controller
58-
- KAFKA_CFG_LISTENERS=CLIENT://:${KAFKA_CLIENT_PORT},INTERNAL://:${KAFKA_INTERNAL_PORT},EXTERNAL://:${KAFKA_EXTERNAL_PORT},
59-
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,CLIENT:SASL_PLAINTEXT,EXTERNAL:SASL_PLAINTEXT
60-
- KAFKA_CFG_ADVERTISED_LISTENERS=CLIENT://kafka:${KAFKA_CLIENT_PORT},EXTERNAL://kafka:${KAFKA_EXTERNAL_PORT}
61-
- KAFKA_CFG_INTER_BROKER_LISTENER_NAME=CLIENT
62-
- KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL=PLAIN
63-
- KAFKA_CFG_SASL_ENABLED_MECHANISMS=PLAIN
64-
- KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=true
65-
- KAFKA_CLIENT_USERS=${KAFKA_CLIENT_USERS}
66-
- KAFKA_CLIENT_PASSWORDS=${KAFKA_USER_PASSWORD}
67-
- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=INTERNAL
68-
69-
- ALLOW_PLAINTEXT_LISTENER=yes
70-
- PRE_CREATE_TOPICS=${PRE_CREATE_TOPICS}
71-
ports:
72-
- ${KAFKA_CLIENT_PORT}:${KAFKA_CLIENT_PORT}
73-
- ${KAFKA_EXTERNAL_PORT}:${KAFKA_EXTERNAL_PORT}
74-
command:
75-
- bash
76-
- -c
77-
- |
78-
(
79-
IFS="," read -ra TOPICS <<< "$$PRE_CREATE_TOPICS";
80-
for T in "$${TOPICS[@]}"; do
81-
/opt/bitnami/kafka/bin/kafka-topics.sh \
82-
--bootstrap-server kafka:9092 \
83-
--create --topic "$$T" --if-not-exists &&
84-
echo "Created $$T" ||
85-
echo "Failed to create $$T";
86-
done;
87-
) & /opt/bitnami/scripts/kafka/run.sh
88-
89-
kafka-ui:
90-
container_name: passimx-kafka-ui
91-
image: provectuslabs/kafka-ui:latest
92-
restart: always
93-
depends_on:
94-
- kafka
95-
networks:
96-
- main
97-
env_file: .env
98-
environment:
99-
- SERVER_SERVLET_CONTEXT_PATH=${SERVER_SERVLET_CONTEXT_PATH}
100-
- KAFKA_CLUSTERS_0_NAME=${KAFKA_UI_HOST}
101-
- KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=${KAFKA_HOST}:${KAFKA_CLIENT_PORT}
102-
- KAFKA_CLUSTERS_0_PROPERTIES_SECURITY_PROTOCOL=SASL_PLAINTEXT
103-
- KAFKA_CLUSTERS_0_PROPERTIES_SASL_MECHANISM=PLAIN
104-
- >
105-
KAFKA_CLUSTERS_0_PROPERTIES_SASL_JAAS_CONFIG=org.apache.kafka.common.security.plain.PlainLoginModule
106-
required
107-
username="${KAFKA_CLIENT_USERS}"
108-
password="${KAFKA_USER_PASSWORD}";
109-
ports:
110-
- ${KAFKA_UI_PORT}:${KAFKA_UI_PORT}
111-
112-
1133
webdav:
1144
image: bytemark/webdav
1155
ports:
1166
- ${WEBDAV_PORT}:80
1177
volumes:
118-
- ./dav-data:/var/lib/dav
8+
- ./data/dav-data:/var/lib/dav
1199
environment:
12010
- AUTH_TYPE=Basic
12111
- USERNAME=${USER_NAME_WEBDAV}

env.example

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# main
2+
APP_HOST_FILES=localhost
3+
APP_PORT_FILES=7021
4+
5+
# webdav
6+
WEBDAV_HOST=http://localhost
7+
WEBDAV_PORT=80
8+
USER_NAME_WEBDAV=admin
9+
PASSWORD_WEBDAV=secrets
10+
11+
# kafka
12+
KAFKA_HOST=localhost
13+
KAFKA_EXTERNAL_PORT=9094
14+
KAFKA_CLIENT_USERS=user
15+
KAFKA_USER_PASSWORD=bitnami
16+
KAFKA_GROUP_ID=ramil-notifications-service
17+
KAFKA_IS_CONNECT=true

0 commit comments

Comments
 (0)