Skip to content

Commit 6063b9f

Browse files
committed
chore: refactor
1 parent 62b24ef commit 6063b9f

File tree

14 files changed

+84
-77
lines changed

14 files changed

+84
-77
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ config.auth.json
3939
config.db.json
4040

4141
media
42-
tsconfig.tsbuildinfo
42+
tsconfig.tsbuildinfo
43+
44+
data

config.dummy.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"base": "/Users/duongtat/Work/cctv/data",
3+
"manifest": "manifest.m3u8",
4+
"maxAge": 604800,
5+
"syncInterval": 3600,
6+
"cleanupPolling": 60,
7+
"segmentSize": 3,
8+
"targets": {
9+
"VENKU": {
10+
"name": "dummy",
11+
"rtsp": "rtsp://172.16.1.160:8554/dummy"
12+
}
13+
}
14+
}

next.config.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
...config,
1818
entry() {
1919
return config.entry().then(async (entry) => {
20-
const targets = ["src/workers", "src/scripts"]
20+
const targets = ["src/server"]
2121

2222
let workerEntries = {}
2323
for (const target of targets) {
@@ -26,12 +26,14 @@ module.exports = {
2626

2727
workerEntries = {
2828
...workerEntries,
29-
...workers.reduce((memo, filename) => {
30-
if (!filename.includes(".ts")) return memo
31-
const name = filename.split(".").shift()
32-
memo[name] = path.resolve(targetDir, filename)
33-
return memo
34-
}, {}),
29+
...Object.fromEntries(
30+
workers
31+
.filter((filename) => filename.includes(".ts"))
32+
.map((filename) => [
33+
filename.split(".").shift(),
34+
path.resolve(targetDir, filename),
35+
])
36+
),
3537
}
3638
}
3739

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {
6-
"start": "node ./.next/server/start.js",
76
"dev": "next dev",
8-
"start:next": "next start",
7+
"start": "next start",
8+
"build": "next build",
99
"start:sync": "node ./.next/server/sync.js",
1010
"start:cleanup": "node ./.next/server/cleanup.js",
1111
"start:worker": "node ./.next/server/worker.js",
12-
"build": "next build",
1312
"fix": "run-p -lsc fix:*",
1413
"fix:eslint": "eslint --fix src",
1514
"fix:prettier": "prettier --write \"src/**/*.ts*\"",

src/components/HLSPlayer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function HLSPlayer(props: { source: string }) {
7373

7474
return (
7575
<>
76-
<video ref={ref} autoPlay playsInline />
76+
<video ref={ref} autoPlay playsInline muted />
7777
{paused && (
7878
<div
7979
css={css`

src/pages/_app.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,3 @@ export default function App(props: AppProps) {
100100
</ConfigContext.Provider>
101101
)
102102
}
103-
104-
App.getInitialProps = async (): Promise<AppInitialProps> => {
105-
const { config } = await loadServerConfig()
106-
return {
107-
pageProps: { config },
108-
}
109-
}

src/pages/camera/[cameraKey].tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { StreamContext } from "utils/stream"
99
import { NextSeo } from "next-seo"
1010
import { encodeQuery } from "utils/query"
1111
import Head from "next/head"
12+
import { GetServerSideProps } from "next"
13+
import { loadServerConfig } from "shared/config"
1214

1315
function generateUrl(
1416
name: string,
@@ -89,3 +91,11 @@ export default function Page() {
8991
</Fragment>
9092
)
9193
}
94+
95+
export const getServerSideProps: GetServerSideProps = async (ctx) => {
96+
const { config } = await loadServerConfig()
97+
98+
return {
99+
props: { config },
100+
}
101+
}

src/pages/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { Fragment, useContext, useEffect } from "react"
55
import { SleepContext } from "utils/sleep"
66
import { useRouter } from "next/router"
77
import Head from "next/head"
8+
import { GetServerSideProps } from "next"
9+
import { loadServerConfig } from "shared/config"
810

911
export default function Page() {
1012
const router = useRouter()
@@ -179,3 +181,13 @@ export default function Page() {
179181
</Fragment>
180182
)
181183
}
184+
185+
export const getServerSideProps: GetServerSideProps = async (ctx) => {
186+
const { config } = await loadServerConfig()
187+
188+
return {
189+
props: {
190+
config,
191+
},
192+
}
193+
}

src/scripts/start.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)