Skip to content

Commit

Permalink
feat: first public commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Zakharov committed Jul 22, 2023
1 parent 5527932 commit 47e8ec8
Show file tree
Hide file tree
Showing 154 changed files with 8,633 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"plugins": [
[
"effector/babel-plugin",
{ "factories": ["@withease/factories", "@farfetched/core"] }
]
]
}
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CLIENT_VERSION=development
CLIENT_HIGHLIGHT_PROJECT_ID=3ff74g32
CLIENT_API_URL=https://192.168.1.127:3001/api
CLIENT_DEV_INIT_DATA=query_id=AAGen5McBDFHSJ6flBxFANw9&user=%7B%22id%22%3A499999999%2C%22first_name%22%3A%22%D0%9A%D0%B8%D1%82%D0%B8%D0%BA%D0%B5%D1%82%22%2C%22last_name%22%3A%22%22%2C%22username%22%3A%22risen322%22%2C%22language_code%22%3A%22en%22%2C%22is_premium%22%3Atrue%7D&auth_date=1686300999&hash=55b29bdcb08d09125eedb5a2eb313f66fa117958ce7ffaa466a45f98cf17151c
20 changes: 20 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { configure, presets } = require('eslint-kit')

module.exports = configure({
allowDebug: process.env.NODE_ENV !== 'production',

presets: [
presets.imports(),
presets.node(),
presets.prettier(),
presets.typescript(),
presets.react(),
presets.effector(),
],

extend: {
rules: {
'effector/mandatory-scope-binding': 'off',
},
},
})
10 changes: 10 additions & 0 deletions .github/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
feature: ['feature/*', 'feat/*']
refactor: ['refactor/*']
fix: ['fix/*', 'bugfix/*', 'hotfix/*']
style: ['style/*']
chore: ['chore/*']
dependencies: ['deps/*', 'renovate/*']
ci: ['ci/*']
documentation: ['docs/*']
tests: ['tests/*']
optimization: ['optimization/*']
56 changes: 56 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
categories:
- title: '⚠️ Breaking changes'
label: 'BREAKING CHANGES'

- title: '🚀 Features'
label: 'feature'

- title: '🛠 Refactor'
label: 'refactor'

- title: '🐛 Bug Fixes'
label: 'fix'

- title: '💅 Style'
label: 'style'

- title: '🧰 Maintenance'
labels:
- 'chore'
- 'dependencies'
- 'ci'

- title: '📚 Documentation'
label: 'documentation'

- title: '🧪 Tests'
label: 'tests'

- title: '🏎 Optimizations'
label: 'optimizations'

version-resolver:
major:
labels:
- 'BREAKING CHANGES'
minor:
labels:
- 'feature'
- 'enhancement'
- 'dependencies'
patch:
labels:
- 'fix'
- 'bugfix'
- 'bug'
- 'optimizations'
- 'refactor'
- 'style'
default: patch

name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'

change-template: '- $TITLE #$NUMBER (@$AUTHOR)'
template: |
$CHANGES
13 changes: 13 additions & 0 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: PR Labeler

on:
pull_request:
types: [opened]

jobs:
pr-labeler:
runs-on: ubuntu-latest
steps:
- uses: TimonVS/pr-labeler-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 15 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Release Drafter

on:
push:
branches: [main]

jobs:
update-release-draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release

on:
release:
types: [published]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Setup git
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "<>"
- name: Checkout main
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-node@v1
with:
node-version: 18
registry-url: https://registry.npmjs.org/

- name: Login to Github Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
.env
*.local
public/env.js
public/sprite.svg
src/shared/ui/general/icon/sprites.generated.ts

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

.yarn/*
!.yarn/releases
!.yarn/patches
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"quoteProps": "consistent"
}
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM node:18-alpine as base

###################
# DEPS
###################

FROM base AS deps
WORKDIR /deps

COPY package.json yarn.lock* ./

RUN yarn install --frozen-lockfile && yarn cache clean

###################
# BUILD
###################

FROM base AS build
WORKDIR /build

COPY --from=deps /deps/node_modules ./node_modules
COPY . .

RUN yarn build

###################
# FINAL
###################

FROM node:18-alpine AS final
WORKDIR /final

RUN apk update
RUN apk add nginx

COPY --from=build /build/dist ./
COPY --from=build /build/nginx.conf /etc/nginx/nginx.conf
COPY --from=build /build/scripts /scripts
COPY --from=build /build/entrypoint.sh /

ENV NODE_ENV production

ENTRYPOINT ["/entrypoint.sh"]
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Russia Consulate Bot WebApp

## Development

1. `cp .env.example .env`
2. `yarn dev`
3. The app is ready at https://192.168.1.127:3001

### Local settings

To open the Web App in your browser, you can mock the init_data value using the `DEV_INIT_DATA` env-variable. The value of init_data can be retrieved through the console inside the Web App in Telegram: `Telegram.WebApp.initData`.

### Bot setup

1. Go to [BotFather](https://t.me/botfather)
2. Create a new bot
3. Select the bot in the BotFather menu
4. Go to `Bot Settings` -> `Menu Button`
5. Choose any name and this link: https://192.168.1.127:3001
6. Now you can see a menu button that opens your Web App when clicked

### Certificate renewing

- Install [mkcert](https://github.com/FiloSottile/mkcert)
- Execute `yarn certs:generate`
12 changes: 12 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env sh

echo "Current environment:"
printenv

echo "Generating env"
node /scripts/generate-env.mjs

echo "Updated index.html:"
cat /final/index.html

nginx -g "daemon off;"
16 changes: 16 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<script type="module" src="/env.js"></script>
<script src="https://telegram.org/js/telegram-web-app.js"></script>
<script>Telegram.WebApp.expand()</script>
<title>Russia Consulate WebApp</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<meta name="robots" content="noindex">
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
events {
worker_connections 4096;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format compression '$remote_addr - $remote_user [$time_local] '
'"$request" $status $upstream_addr '
'"$http_referer" "$http_user_agent"';

server {
listen 80;
access_log /var/log/nginx/access.log compression;

gzip on;
gzip_types text/html application/javascript application/json text/css;

root /final;
index index.html;

location / {
try_files $uri $uri/ $uri.html /index.html;
}
}
}
Loading

0 comments on commit 47e8ec8

Please sign in to comment.