forked from ytgov/internal-data-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from icefoganalytics/issue-6/add-minimal-front…
…-end-dockerize-setup Add Minimal Front-End Dockerize Setup
- Loading branch information
Showing
37 changed files
with
6,168 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,37 @@ | ||
import path from "path" | ||
import fs from "fs" | ||
|
||
import { Router, type Request, type Response } from "express" | ||
import { template } from "lodash" | ||
|
||
import { GIT_COMMIT_HASH, RELEASE_TAG } from "@/config" | ||
import { APPLICATION_NAME, GIT_COMMIT_HASH, RELEASE_TAG } from "@/config" | ||
|
||
export const router = Router() | ||
|
||
// some routes | ||
router.route("/_status").get((req: Request, res: Response) => { | ||
res.json({ | ||
return res.json({ | ||
RELEASE_TAG, | ||
GIT_COMMIT_HASH, | ||
}) | ||
}) | ||
|
||
// if no other api routes match, send the 404 page | ||
router.use("/api", (req: Request, res: Response) => { | ||
const templatePath = path.resolve(__dirname, "web/404.html") | ||
try { | ||
const templateString = fs.readFileSync(templatePath, "utf8") | ||
const compiledTemplate = template(templateString) | ||
const result = compiledTemplate({ | ||
applicationName: APPLICATION_NAME, | ||
releaseTag: RELEASE_TAG, | ||
gitCommitHash: GIT_COMMIT_HASH, | ||
}) | ||
return res.status(404).send(result) | ||
} catch (error) { | ||
console.error(error) | ||
return res.status(500).send(`Error building 404 page: ${error}`) | ||
} | ||
}) | ||
|
||
export default router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function stripTrailingSlash(url: string) { | ||
return url.endsWith("/") ? url.slice(0, -1) : url | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1.0" | ||
/> | ||
<title>404 Not Found</title> | ||
<style> | ||
body { | ||
text-align: center; | ||
padding-top: 100px; | ||
} | ||
hr { | ||
margin-top: 30px; | ||
margin-bottom: 30px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>Error 404</h1> | ||
<p>Oops! The page you're looking doesn't exist.</p> | ||
<hr /> | ||
<p>Site: ${applicationName}</p> | ||
<p>Version: ${releaseTag}</p> | ||
<p>Commit Hash: ${gitCommitHash}</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
> 1% | ||
last 2 versions | ||
not dead | ||
not ie 11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// https://github.com/typescript-eslint/typescript-eslint/issues/251 | ||
export default { | ||
root: true, | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
node: true, | ||
}, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:vue/vue3-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier", | ||
], | ||
overrides: [], | ||
parser: "vue-eslint-parser", | ||
parserOptions: { | ||
ecmaVersion: "latest", | ||
extraFileExtensions: [".vue"], | ||
parser: "@typescript-eslint/parser", | ||
tsconfigRootDir: __dirname, | ||
project: ["./tsconfig.node.json", "./tsconfig.json"], | ||
sourceType: "module", | ||
}, | ||
plugins: ["vue", "@typescript-eslint"], | ||
rules: {}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
coverage | ||
*.local | ||
|
||
/cypress/videos/ | ||
/cypress/screenshots/ | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
{ | ||
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] | ||
"recommendations": [ | ||
"Vue.volar", | ||
"Vue.vscode-typescript-vue-plugin", | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Vue 3 + TypeScript + Vite | ||
|
||
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more. | ||
|
||
## Recommended IDE Setup | ||
|
||
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin). | ||
|
||
## Type Support For `.vue` Imports in TS | ||
|
||
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types. | ||
|
||
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps: | ||
|
||
1. Disable the built-in TypeScript Extension | ||
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette | ||
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)` | ||
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM node:20.10.0-alpine3.19 | ||
|
||
WORKDIR /usr/src/web | ||
|
||
COPY package*.json ./ | ||
|
||
RUN npm install | ||
|
||
COPY . . | ||
|
||
CMD ["npm", "run", "start", "--", "--host", "0.0.0.0"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<link | ||
rel="preconnect" | ||
href="https://fonts.googleapis.com" | ||
/> | ||
<link | ||
rel="preconnect" | ||
href="https://fonts.gstatic.com" | ||
crossorigin | ||
/> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400;700&display=swap" | ||
rel="stylesheet" | ||
/> | ||
<meta charset="UTF-8" /> | ||
<link | ||
rel="icon" | ||
type="image/ico" | ||
href="/favicon.ico" | ||
/> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1.0" | ||
/> | ||
<title>Internal Data Portal</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script | ||
type="module" | ||
src="/src/main.ts" | ||
></script> | ||
</body> | ||
</html> |
Oops, something went wrong.