Skip to content

Commit

Permalink
chore: UI docker, @hikers-book/cli-tools, @hikers-book/config, angula…
Browse files Browse the repository at this point in the history
…r improves
  • Loading branch information
radoslavirha committed Sep 30, 2023
1 parent ee8ac41 commit cb4877b
Show file tree
Hide file tree
Showing 75 changed files with 10,892 additions and 15,501 deletions.
Binary file added .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*/coverage
*/dist
*/node_modules
*/.DS_Store
*/**/config.json
24 changes: 24 additions & 0 deletions Dockerfile.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:18 as build-stage
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
RUN pnpm install -g @angular/cli

WORKDIR /app

COPY package.json .
COPY pnpm-lock.yaml .
COPY pnpm-workspace.yaml .
COPY tsconfig.json .

COPY ui/hikers-book/package.json ui/hikers-book/package.json

RUN pnpm --filter hikers-book-ui install

COPY ui/hikers-book ui/hikers-book

RUN pnpm --filter hikers-book-ui run build

FROM nginx:1.25
COPY --from=build-stage /app/ui/hikers-book/dist/ /usr/share/nginx/html
COPY ./docker/nginx/hikers-book.conf /etc/nginx/conf.d/default.conf
2 changes: 2 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
Memories, guides, tips, gearlists and many more!

**Work in progress !!!**

[Documentation](./docs/Readme.md)
1 change: 1 addition & 0 deletions api/graphql/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config/*.json
File renamed without changes.
24 changes: 20 additions & 4 deletions api/graphql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hikers-book/graphql-api",
"version": "1.0.0",
"version": "0.1.0",
"description": "GraphQL API",
"author": "radoslav.irha@gmail.com",
"license": "MIT",
Expand All @@ -13,7 +13,11 @@
"lint": "eslint --ext .ts src",
"test": "pnpm run test:coverage",
"test:unit": "cross-env NODE_ENV=test jest",
"test:coverage": "pnpm run test:unit"
"test:coverage": "pnpm run test:unit",
"config": "hikers-book-config-cli -s node_modules/@hikers-book/config/config/api.graphql.json -t config/default.json -f json || true",
"config:test": "hikers-book-config-cli -s node_modules/@hikers-book/config/config/api.graphql.json -t config/test.json -f json || true",
"config:env": "hikers-book-config-cli -s node_modules/@hikers-book/config/environment-variables/api.graphql.json -t config/custom-environment-variables.json -f json || true",
"postinstall": "pnpm run config:env && pnpm run config && pnpm run config:test"
},
"dependencies": {
"@tsed/ajv": "^7.34.6",
Expand Down Expand Up @@ -47,6 +51,7 @@
"body-parser": "^1.20.2",
"class-validator": "^0.13.2",
"compression": "^1.7.4",
"config": "^3.3.9",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"cross-env": "^7.0.3",
Expand All @@ -60,13 +65,17 @@
"type-graphql": "^1.1.1"
},
"devDependencies": {
"@hikers-book/cli-tools": "workspace:*",
"@hikers-book/config": "workspace:*",
"@hikers-book/eslint-config": "workspace:*",
"@tsed/apollo": "^7.34.6",
"@tsed/cli-plugin-eslint": "4.6.4",
"@tsed/cli-plugin-jest": "4.6.4",
"@tsed/cli-plugin-mongoose": "4.6.4",
"@tsed/cli-plugin-typegraphql": "4.6.4",
"@tsed/testing-mongoose": "^7.34.6",
"@types/compression": "^1.7.2",
"@types/config": "^3.3.1",
"@types/cookie-parser": "^1.4.3",
"@types/cors": "^2.8.13",
"@types/express": "^4.17.17",
Expand All @@ -76,7 +85,6 @@
"@types/node": "^20.5.7",
"@types/supertest": "^2.0.12",
"@types/validator": "^13.11.1",
"@hikers-book/eslint-config": "workspace:*",
"apollo-server-testing": "^2.25.3",
"graphql-tag": "^2.12.6",
"jest": "^29.6.4",
Expand All @@ -92,5 +100,13 @@
"convention": "conv_default",
"architecture": "arc_default",
"packageManager": "pnpm"
}
},
"engines": {
"node": ">= 18.0.0",
"pnpm": ">= 8.7.0"
},
"os": [
"darwin",
"linux"
]
}
23 changes: 0 additions & 23 deletions api/graphql/processes.config.js

This file was deleted.

2 changes: 0 additions & 2 deletions api/graphql/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import './resolvers/index';
@Configuration({
...config,
acceptMimes: ['application/json'],
httpPort: process.env.PORT || 8083,
httpsPort: false, // CHANGE
disableComponentsScan: true,
mount: {
'/rest': [...Object.values(rest)],
Expand Down
1 change: 1 addition & 0 deletions api/graphql/src/config/envs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export const envs = {
// eslint-disable-next-line import/no-named-as-default-member
...dotenv.config().parsed
};

export const isProduction = process.env.NODE_ENV === 'production';
3 changes: 3 additions & 0 deletions api/graphql/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import cfg from 'config';
import { readFileSync } from 'fs';
import { envs } from './envs/index';
import loggerConfig from './logger/index';
Expand All @@ -7,6 +8,8 @@ const pkg = JSON.parse(readFileSync('./package.json', { encoding: 'utf8' }));

export const config: Partial<TsED.Configuration> = {
version: pkg.version,
httpPort: cfg.get<string>('server.httpPort'),
httpsPort: cfg.get<string>('server.httpsPort'),
envs,
logger: loggerConfig,
mongoose: mongooseConfig,
Expand Down
5 changes: 0 additions & 5 deletions api/graphql/src/config/mongoose/default.config.ts

This file was deleted.

12 changes: 9 additions & 3 deletions api/graphql/src/config/mongoose/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// @tsed/cli do not edit
import defaultConfig from './default.config';
import cfg from 'config';
import { ConnectOptions } from 'mongoose';

export default [defaultConfig];
export default [
{
id: 'hikers-book',
url: cfg.get<string>('mongodb.url'),
connectionOptions: cfg.get<ConnectOptions>('mongodb.connectionOptions')
}
];
29 changes: 0 additions & 29 deletions api/graphql/src/controllers/pages/IndexController.ts

This file was deleted.

6 changes: 1 addition & 5 deletions api/graphql/src/controllers/pages/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
/**
* @file Automatically generated by barrelsby.
*/

export * from './IndexController';
export default {};
Empty file added api/graphql/views/.gitkeep
Empty file.
100 changes: 0 additions & 100 deletions api/graphql/views/swagger.ejs

This file was deleted.

3 changes: 3 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ services:
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
MONGO_INITDB_DATABASE: hikers-book
ports:
- 27017:27017
volumes:
- ./mongo/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
mongo-express:
image: mongo-express:latest
container_name: mongo-express
Expand Down
12 changes: 12 additions & 0 deletions docker/mongo/mongo-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
db.createUser(
{
user: "hiker",
pwd: "hikers_password",
roles: [
{
role: "readWrite",
db: "hikers-book"
}
]
}
);
35 changes: 35 additions & 0 deletions docker/nginx/hikers-book.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Browser preferred language detection (does NOT require
# AcceptLanguageModule)
map $http_accept_language $accept_language {
~*^cs cs;
~*^en-US en-US;
~*^sk sk;
}

server {
listen 80;
root /usr/share/nginx/html;

# Fallback to default language if no preference defined by browser
if ($accept_language ~ "^$") {
set $accept_language "en-US";
}

# Redirect "/" to Angular application in the preferred language of the browser
rewrite ^/$ /$accept_language permanent;

# mount config as volume only once to root, not to each language
location ~ /assets/config.json$ {
try_files $uri /config.json;
}

# Everything under the Angular application is always redirected to Angular in the
# correct language
location ~ ^/(cs|en-US|sk) {
try_files $uri /$1/index.html?$args;
}

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

0 comments on commit cb4877b

Please sign in to comment.