Skip to content
This repository was archived by the owner on Feb 14, 2024. It is now read-only.

Commit a82175e

Browse files
fix: general (#17)
* fix: nestjs env * fix: package json scope * fix: docker-compose * fix: nestjs validation and nullable fcm json * fix: vue * Update README.md * fix: lint * core: vue-web env add
1 parent dd90c4c commit a82175e

File tree

11 files changed

+111
-72
lines changed

11 files changed

+111
-72
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
1+
2+
![](docs/productdevbook.png)
3+
4+
## Discord
5+
![productdevbook](https://discordapp.com/api/guilds/982896043463180310/widget.png?style=shield)
6+
17
### Website
28
* http://localhost:3000 - vue
39
* http://localhost:5000 - vue-mobile
410
* http://localhost:4000/graphql - api
511

6-
### Setup
12+
# Setup
713

814
```properties
915
pnpm install
10-
pnpm dev
16+
docker-compose up
17+
```
18+
19+
### Env setup
20+
Example env file change name to .env
21+
```
22+
/apps/nestjs/.env.example -> /apps/nestjs/.env
23+
/apps/vue-web/.env.example -> /apps/vue-web/.env
1124
```
25+
26+
### Docker running
27+
```properties
28+
pnpm db:up // migrations db
29+
pnpm dev
30+
```

apps/nestjs/.env.example

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ CORS_ORIGIN=http://localhost:3000,https://studio.apollographql.com,http://localh
66
FALLBACK_LANGUAGE='en'
77

88
# Database config
9-
DATABASE_URL='postgresql://USER:PASSWORD@HOST:PORT/DATABASE'
9+
DATABASE_URL='postgresql://postgres:postgres@localhost:5432/postgres'
1010

1111
# JWT config
12-
JWT_EXPIRES_IN=600
13-
JWT_REFRESH_EXPIRES_IN=604800
12+
JWT_EXPIRES_IN=15m
13+
JWT_REFRESH_EXPIRES_IN=24h
1414
JWT_EXPIRATION_TIME=12h
1515
JWT_AUDIENCE=localhost:3000
1616
JWT_COOKIE_NAME=accessToken
@@ -37,11 +37,10 @@ BUCKET_REGION='bucket_region'
3737
BUCKET_HOST='aws?linode?digitalocean?'
3838

3939
# Redis Server Set up
40-
REDIS_URL='redis://:PASSWORD@HOST:PORT'
40+
REDIS_URL='redis://:@localhost:6379'
4141
REDIS_CACHE_TTL=600
4242

4343
# Graphql Upload
4444
MAX_FILE_SIZE=5242880
4545
MAX_FILES=5
46-
47-
FCM_JSON='{}'
46+
PLAYGROUND=true

apps/nestjs/src/config/validation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const validationSchema = Joi.object({
1313
JWT_PRIVATE_KEY: Joi.string().required(),
1414
JWT_EXPIRES_IN: Joi.string().required(),
1515
JWT_AUDIENCE: Joi.string().required(),
16-
JWT_ISSUER: Joi.string().required(),
16+
JWT_ISSUER: Joi.string(),
1717

1818
JWT_COOKIE_NAME: Joi.string().required(),
1919
JWT_REFRESH_EXPIRES_IN: Joi.string().required(),
@@ -37,6 +37,6 @@ export const validationSchema = Joi.object({
3737
MAX_FILE_SIZE: Joi.number().required(),
3838
MAX_FILES: Joi.number().required(),
3939

40-
FCM_JSON: Joi.string().required(),
40+
FCM_JSON: Joi.string(),
4141

4242
})

apps/nestjs/src/shared/services/notification.service.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import { IConfig } from '@/config/interfaces/config.interface'
77
@Injectable()
88
export class NotificationService {
99
constructor(configService: ConfigService<IConfig>) {
10-
const firebaseCredentials = JSON.parse(configService.get('fcm_json').replace(/'/g, '"'))
11-
firebase.initializeApp({
12-
credential: firebase.credential.cert(firebaseCredentials),
13-
})
10+
if (configService.get('fcm_json')) {
11+
const firebaseCredentials = JSON.parse(configService.get('fcm_json').replace(/'/g, '"'))
12+
firebase.initializeApp({
13+
credential: firebase.credential.cert(firebaseCredentials),
14+
})
15+
}
1416
}
1517

1618
async sendToDevice(title: string, data: Notification = { title: 'Title', body: 'body' }, token: string): Promise<Boolean> {

apps/vue-web/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
VITE_FIREBASE_CONFIG=
2+
VITE_VAPID_KEY=
3+
VITE_SERVER_URL=localhost

apps/vue-web/src/main.ts

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import axios from 'axios'
44
import 'uno.css'
55
import './assets/base.css'
66
import { createHead } from '@vueuse/head'
7-
import { onMessage } from 'firebase/messaging'
8-
import router, { routes } from './router'
9-
import { messaging } from './services/notifications'
10-
import App from './App.vue'
117
// import { onMessage } from 'firebase/messaging'
8+
import router, { routes } from './router'
129
// import { messaging } from './services/notifications'
10+
import App from './App.vue'
1311

1412
const meta = document.createElement('meta')
1513
meta.name = 'naive-ui-style'
@@ -43,41 +41,44 @@ if (import.meta.hot)
4341
import.meta.hot.accept()
4442

4543
init()
46-
onMessage(messaging, (payload) => {
47-
if (payload.notification === undefined)
48-
return
44+
// TODO nullable Firebase messaging
45+
// if (import.meta.env.VITE_FIREBASE_CONFIG) {
46+
// onMessage(messaging, (payload) => {
47+
// if (payload.notification === undefined)
48+
// return
4949

50-
// console.log(payload.data)
51-
const notificationData = payload
50+
// // console.log(payload.data)
51+
// const notificationData = payload
5252

53-
// eslint-disable-next-line no-console
54-
console.log(
55-
'[firebase-messaging-sw.js] Received foreground message ',
56-
notificationData,
57-
)
58-
const { tSuccess } = usePWebNotification()
59-
if (notificationData.data)
60-
tSuccess({ title: notificationData.data.title, description: notificationData.data.body })
53+
// // eslint-disable-next-line no-console
54+
// console.log(
55+
// '[firebase-messaging-sw.js] Received foreground message ',
56+
// notificationData,
57+
// )
58+
// const { tSuccess } = usePWebNotification()
59+
// if (notificationData.data)
60+
// tSuccess({ title: notificationData.data.title, description: notificationData.data.body })
6161

62-
const { title, body } = notificationData.data as { title: string; body: string }
63-
const notificationTitle = title
64-
const notificationOptions = {
65-
body,
66-
icon: '/logo-dark.png',
67-
}
62+
// const { title, body } = notificationData.data as { title: string; body: string }
63+
// const notificationTitle = title
64+
// const notificationOptions = {
65+
// body,
66+
// icon: '/logo-dark.png',
67+
// }
6868

69-
navigator.serviceWorker.ready.then((registration) => {
70-
registration
71-
.showNotification(notificationTitle, notificationOptions)
72-
.then(() => {
73-
// eslint-disable-next-line no-console
74-
console.log('[firebase-messaging-sw.js] Notification shown')
75-
})
76-
.catch((error) => {
77-
console.error(
78-
'[firebase-messaging-sw.js] Error showing notification',
79-
error,
80-
)
81-
})
82-
})
83-
})
69+
// navigator.serviceWorker.ready.then((registration) => {
70+
// registration
71+
// .showNotification(notificationTitle, notificationOptions)
72+
// .then(() => {
73+
// // eslint-disable-next-line no-console
74+
// console.log('[firebase-messaging-sw.js] Notification shown')
75+
// })
76+
// .catch((error) => {
77+
// console.error(
78+
// '[firebase-messaging-sw.js] Error showing notification',
79+
// error,
80+
// )
81+
// })
82+
// })
83+
// })
84+
// }

apps/vue-web/src/pages/auth/login.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import type { SchemaOf } from 'yup'
88
import { boolean, object, string } from 'yup'
99
import type { SignInInput } from '@oku/api'
1010
import { useI18n } from 'vue-i18n'
11-
import { initNotif } from '~/services/notifications'
1211
1312
const userStore = useUserStore()
1413
const { t } = useI18n()
@@ -61,7 +60,6 @@ const onSubmit = form.handleSubmit(async (values) => {
6160
{
6261
onSuccess: (res) => {
6362
// router.push(res)
64-
initNotif()
6563
},
6664
onLoading: (res) => {
6765
isLoading.value = res

docker-compose.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
version: "3.9"
2-
32
services:
4-
monorepo:
3+
postgres:
54
image: postgres:latest
65
platform: linux/x86_64
76
restart: unless-stopped
87
ports:
9-
- 62162:5432
8+
- 5432:5432
109
environment:
1110
- POSTGRES_DB=postgres
1211
- POSTGRES_USER=postgres
1312
- POSTGRES_PASSWORD=postgres
1413
volumes:
1514
- monorepo:/var/lib/postgresql/data
15+
- ./initdb:/docker-entrypoint-initdb.d
1616

17-
redisnonorepo:
17+
redis:
1818
image: redis:latest
1919
restart: unless-stopped
2020
ports:
@@ -27,4 +27,4 @@ services:
2727
volumes:
2828
monorepo:
2929
driver: local
30-
name: monorepo
30+
name: monorepo

docs/productdevbook.png

11.8 KB
Loading

initdb/extensions.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -e
3+
set -u
4+
sleep 10
5+
6+
main() {
7+
echo "CREATING UUID-OSSP and pgcrypto EXTENSIONS"
8+
create_extensions
9+
echo "EXTENSIONS CREATED SUCCESSFULLY"
10+
}
11+
12+
13+
create_extensions() {
14+
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
15+
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
16+
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
17+
EOSQL
18+
}
19+
20+
main "$@"
21+

package.json

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
"workspaces": ["apps/*", "packages/*"],
55
"scripts": {
66
"dev": "turbo run dev --parallel --no-cache",
7-
"dev:vue-storybook": "turbo run dev --parallel --no-cache --scope=@productdevbook/storybook-vue",
8-
"dev:web": "turbo run dev --parallel --no-cache --scope=vue-web --scope=@oku/api --scope=app-nestjs --scope=oku-i18n",
9-
"dev:mobile": "turbo run dev --parallel --no-cache --scope=vue-mobile --scope=@oku/api --scope=app-nestjs --scope=oku-i18n",
10-
"dev:ui:web": "turbo run dev --parallel --no-cache --scope=vue-web --scope=@productdevbook/storybook-vue",
11-
"dev:ui:mobile": "turbo run dev --parallel --no-cache --scope=vue-mobile --scope=@productdevbook/storybook-vue",
7+
"dev:vue-storybook": "turbo run dev --parallel --no-cache --filter=@productdevbook/storybook-vue",
8+
"dev:web": "turbo run dev --parallel --no-cache --filter=vue-web --filter=@oku/api --filter=app-nestjs --filter=oku-i18n",
9+
"dev:mobile": "turbo run dev --parallel --no-cache --filter=vue-mobile --filter=@oku/api --filter=app-nestjs --filter=oku-i18n",
10+
"dev:ui:web": "turbo run dev --parallel --no-cache --filter=vue-web --filter=@productdevbook/storybook-vue",
11+
"dev:ui:mobile": "turbo run dev --parallel --no-cache --filter=vue-mobile --filter=@productdevbook/storybook-vue",
1212
"dev:nestjs": "turbo run dev --filter=app-nestjs",
1313
"build": "turbo run build",
14-
"build:nestjs": "turbo run build --parallel --scope=app-nestjs",
15-
"build:vue-web": "turbo run build --parallel --scope=vue-web",
16-
"build:vue-mobile": "turbo run build --parallel --scope=vue-mobile",
14+
"build:nestjs": "turbo run build --parallel --filter=app-nestjs",
15+
"build:vue-web": "turbo run build --parallel --filter=vue-web",
16+
"build:vue-mobile": "turbo run build --parallel --filter=vue-mobile",
1717
"app": "pnpm --filter vue-mobile refresh",
1818
"run:android": "pnpm --filter vue-mobile ionic capacitor run android",
1919
"run:ios": "pnpm --filter vue-mobile ionic capacitor run ios",
@@ -26,7 +26,7 @@
2626
"db:update": "pnpm --filter app-nestjs migrate:update",
2727
"db:push": "pnpm --filter app-nestjs migrate:push",
2828
"db:delete": "pnpm --filter app-nestjs migrate:drop",
29-
"db:data": "pnpm --filternestjs mikro-orm seeder:run",
29+
"db:data": "pnpm --filter nestjs mikro-orm seeder:run",
3030
"db:revert": "pnpm --filter app-nestjs migrate:revert",
3131
"db:show": "pnpm --filter app-nestjs migrate:show",
3232
"generate": "pnpm --filter @oku/api build && pnpm --filter api app:create",
@@ -59,10 +59,6 @@
5959
"vue-mobile": "workspace:*",
6060
"vue-web": "workspace:*"
6161
},
62-
"engines": {
63-
"npm": "8.x",
64-
"node": "16.x"
65-
},
6662
"packageManager": "[email protected]",
6763
"dependencies": {
6864
"add": "2.0.6",

0 commit comments

Comments
 (0)