Skip to content

Commit

Permalink
Enhance/translations and wallet issues and other (#1030)
Browse files Browse the repository at this point in the history
* issue #1006 #1021

* `update` .github/deploy script

* issue #1019

* `renaming`

* `aesthetic` `doc`

* `update` for `docker:dev` + `package.json` scripts

* `update` with `main`

* `update` settings.json

* issue #951

* issue #951

* issue #951

* issue #951 `redundant` code

* issue #951

* issue #1028

* issue #951 `styles` update

* `deepsource` JS-0128
  • Loading branch information
migbash authored Feb 1, 2023
1 parent 130d767 commit c76202a
Show file tree
Hide file tree
Showing 50 changed files with 2,881 additions and 582 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ jobs:
# [ℹ] Navigate to target project directory
cd web/scores
# [ℹ] Update the directory with latests changes
git pull origin enhance/feature-docker-deploy
git pull origin main
# [ℹ] Run target makefile command
make update-scores-web
make update-scores-web
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
- name: Build the Docker image
run: |
docker build . --file Dockerfile --tag my-image-name:$(date +%s)
# run: docker build --no-cache --progress=plain --tag scores-platform:$(date +%s) .
# run: docker build --no-cache --progress=plain --tag scores-platform:$(date +%s) .
9 changes: 5 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
// https://stackoverflow.com/questions/64365300/how-can-i-remove-unused-imports-declarations-from-the-entire-project-of-react-ty
// https://stackoverflow.com/questions/46722701/is-there-a-way-to-remove-unused-imports-and-declarations-from-angular-2
// DOC: https://stackoverflow.com/questions/64365300/how-can-i-remove-unused-imports-declarations-from-the-entire-project-of-react-ty
// DOC: https://stackoverflow.com/questions/46722701/is-there-a-way-to-remove-unused-imports-and-declarations-from-angular-2
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true,
"source.sortMembers": true
"source.organizeImports": true,
"source.sortMembers": true
},
// NOTE: custom highlighter for data
"todohighlight.keywords": [
{
"text": "NOTE:",
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ COPY . .

EXPOSE 5055
# CMD ["node", "./build"]
CMD ["npm", "start"]
CMD ["npm", "run", "start:docker"]
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ EXPOSE 5055
EXPOSE 24678

# CMD ["node", "./build"]
CMD ["npm", "run", "dev-docker"]
CMD ["npm", "run", "dev:docker"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ log-listen:

update-scores-web:
echo 'Updating PROD Scores Web container...'
git pull origin enhance/feature-docker-deploy
git pull origin main
-docker rm $$(docker stop $$(docker ps -a -q --filter="name=scores_scores_web_1" --format="{{.ID}}"))
-docker rmi $$(docker images -q scores_web)
-docker rmi $$(docker images --filter "dangling=true" -q --no-trunc)
Expand Down
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: npm run start:heroku
File renamed without changes.
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
"node": "16.17.0"
},
"scripts": {
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. .",
"debug": "cross-env NODE_OPTIONS='--inspect' vite dev --host --port 3050",
"debug-preview": "cross-env NODE_OPTIONS='--inspect' vite preview --host --port 5000",
"debug-bull": "cross-env NODE_DEBUG='bull' vite preview --host --port 5000",
"debug:bull": "cross-env NODE_DEBUG='bull' vite preview --host --port 5000",
"debug:preview": "cross-env NODE_OPTIONS='--inspect' vite preview --host --port 5000",
"dev": "vite dev --host --port 3050",
"dev-docker": "vite dev --host --port 5055",
"docker-dev-up": "docker-compose -f docker-compose.dev.yml up",
"build": "vite build",
"dev:docker": "vite dev --host --port 5055",
"dev:docker:up": "docker-compose -f docker-compose.dev.yml up",
"staging": "npm run dev -- --mode staging",
"start": "node my-server.js",
"build": "vite build",
"preview": "vite preview --host --port 5000",
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
"start:docker": "node server-docker.js",
"start:heroku": "node server-heroku.js"
},
"devDependencies": {
"@sveltejs/adapter-node": "1.0.0-next.88",
Expand Down
34 changes: 7 additions & 27 deletions my-server.js → server-docker.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// [ℹ] https://github.com/sveltejs/kit/tree/master/packages/adapter-node#custom-server
// [ℹ] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
// DOC: https://github.com/sveltejs/kit/tree/master/packages/adapter-node#custom-server
// DOC: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
import express from 'express';
import http from 'http';
import https from 'https';

import { handler } from './build/handler.js';
// import sslRedirect from 'heroku-ssl-redirect';
import compression from 'compression'; // https://expressjs.com/en/resources/middleware/compression.html
// DOC: https://expressjs.com/en/resources/middleware/compression.html
import compression from 'compression';
import * as sslify from 'express-sslify';
import * as requestIp from 'request-ip'; // https://www.npmjs.com/package/request-ip
// DOC: https://www.npmjs.com/package/request-ip

import fs from 'fs';

Expand All @@ -20,24 +20,11 @@ const options = {

const app = express();

/**
* [ℹ] add a route that lives separately from the SvelteKit app
*/
// app.get('/healthcheck', (req, res) => {
// res.end('ok');
// });

/**
* [ℹ] enable ssl redirect
* [ℹ] https://www.npmjs.com/package/heroku-ssl-redirect
* => does not seem to be working
*/
// app.use(sslRedirect());

/**
* [ℹ] separate from SvelteKit endpoint in attempts to
* [ℹ] identify clients (IP - address)
*/
/**
app.get('/getClientIP', (req, res) => {
const ip = req.headers['x-forwarded-for'] ||
Expand Down Expand Up @@ -69,6 +56,7 @@ app.get('/getClientIP', (req, res) => {
res.end()
})
*/

/**
* [ℹ] [FORCE] https-redirect
Expand Down Expand Up @@ -97,14 +85,6 @@ app.use(compression())
*/
app.use(handler);

/**
* [ℹ] initialize app;
* [ℹ] https://stackoverflow.com/questions/15693192/heroku-node-js-error-web-process-failed-to-bind-to-port-within-60-seconds-o
*/
// app.listen(process.env.PORT, () => {
// console.log(`listening on port ${process.env.PORT}`);
// });

// ~~~~~~~~~~~~~~~~~~~~~~
// APP SPIN-UP [PROD] [V2]
// ~~~~~~~~~~~~~~~~~~~~~~
Expand Down
93 changes: 93 additions & 0 deletions server-heroku.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// DOC: https://github.com/sveltejs/kit/tree/master/packages/adapter-node#custom-server
// DOC: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

import express from 'express';
import { handler } from './build/handler.js';
// import sslRedirect from 'heroku-ssl-redirect';
// DOC: https://expressjs.com/en/resources/middleware/compression.html
import compression from 'compression';
import * as sslify from 'express-sslify';
// DOC: https://www.npmjs.com/package/request-ip

const app = express();

/**
* [ℹ] enable ssl redirect
* DOC: https://www.npmjs.com/package/heroku-ssl-redirect
* => does not seem to be working
*/
// app.use(sslRedirect());

/**
* [ℹ] separate from SvelteKit endpoint in attempts to
* [ℹ] identify clients (IP - address)
*/
/**
app.get('/getClientIP', (req, res, next) => {
const ip = req.headers['x-forwarded-for'] ||
req.socket.remoteAddress ||
null;
console.log('ip', ip);
const ip2 = req.ip
console.log('ip2', ip2);
const ip3 = requestIp.getClientIp(req);
console.log('ip3', ip3);
let ipAddr = req.headers["x-forwarded-for"];
if (ipAddr){
const list = ipAddr.split(",");
ipAddr = list[list.length-1];
} else {
ipAddr = req.connection.remoteAddress;
}
console.log('ipAddr', ipAddr);
res.json(
{
"ip": ip.toString().replace(/,/g, '')
}
);
res.end()
})
*/

/**
* [ℹ] [FORCE] https-redirect
* DOC: https://jaketrent.com/post/https-redirect-node-heroku
* DOC: https://webdva.github.io/how-to-force-express-https-tutorial
* [HEROKU]
*/
app.use((req, res, next) => {
if (req.header('x-forwarded-proto') !== 'https')
res.redirect(`https://${req.header('host')}${req.url}`);
else
next();
});

/**
* DOC: https://www.npmjs.com/package/express-sslify
* DOC: https://stackoverflow.com/questions/51234023/heroku-nodejs-redirect-http-to-http
*/
app.use(sslify.HTTPS({ trustProtoHeader: true }))

// [ℹ] compress all responses
app.use(compression())

/**
* [ℹ] let SvelteKit handle everything else,
* [ℹ] including serving prerendered pages and static assets
*/
app.use(handler);

/**
* [ℹ] initialize app;
* DOC: https://stackoverflow.com/questions/15693192/heroku-node-js-error-web-process-failed-to-bind-to-port-within-60-seconds-o
*/
app.listen(process.env.PORT || 5000, () => {
console.log('listening on port 5000');
});
Loading

0 comments on commit c76202a

Please sign in to comment.