Updated
This commit is contained in:
parent
fec3abd5d8
commit
bcb83dfea5
13 changed files with 1542 additions and 4019 deletions
|
|
@ -1,25 +1,46 @@
|
||||||
import { ofetch } from 'ofetch'
|
import * as fs from "node:fs";
|
||||||
import { $backendUrl, $requestRetries, $requestRetryCodes } from '../../../../configs/config.api'
|
import { ofetch } from "ofetch";
|
||||||
|
import * as toml from "toml";
|
||||||
|
|
||||||
const URL = $backendUrl.get()
|
const config = toml.parse(fs.readFileSync("configs/config.api.toml", "utf-8"));
|
||||||
const RETRY = $requestRetries.get()
|
const URL = config.backend.backend_url;
|
||||||
const CODES = $requestRetryCodes.get()
|
const RETRY = config.request.request_retries;
|
||||||
|
const CODES = config.request.request_retry_codes;
|
||||||
|
|
||||||
export default async (api: string, value?: any, value2?: any) => {
|
export default async (
|
||||||
|
api: string,
|
||||||
|
value?: string | number,
|
||||||
|
value2?: string | number,
|
||||||
|
) => {
|
||||||
try {
|
try {
|
||||||
let fetch
|
let fetch: { [key: string]: unknown };
|
||||||
if (!value2) {
|
if (!value2) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
fetch = await ofetch(URL + api, { parseResponse: JSON.parse, retry: RETRY, retryDelay: 500, retryStatusCodes: CODES })
|
fetch = await ofetch(URL + api, {
|
||||||
|
parseResponse: JSON.parse,
|
||||||
|
retry: RETRY,
|
||||||
|
retryDelay: 500,
|
||||||
|
retryStatusCodes: CODES,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
fetch = await ofetch(URL + `${api}/${value}/fetch-data`, { parseResponse: JSON.parse, retry: RETRY, retryDelay: 500, retryStatusCodes: CODES })
|
fetch = await ofetch(`${URL}${api}/${value}/fetch-data`, {
|
||||||
|
parseResponse: JSON.parse,
|
||||||
|
retry: RETRY,
|
||||||
|
retryDelay: 500,
|
||||||
|
retryStatusCodes: CODES,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fetch = await ofetch(URL + `${api}/${value}/${value2}/fetch-data`, { parseResponse: JSON.parse, retry: RETRY, retryDelay: 500, retryStatusCodes: CODES })
|
fetch = await ofetch(`${URL}${api}/${value}/${value2}/fetch-data`, {
|
||||||
|
parseResponse: JSON.parse,
|
||||||
|
retry: RETRY,
|
||||||
|
retryDelay: 500,
|
||||||
|
retryStatusCodes: CODES,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const result = fetch
|
const result = fetch;
|
||||||
return [result, null]
|
return [result, null];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return [[], error]
|
return [[], error];
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,48 @@
|
||||||
import dayjs from 'dayjs'
|
/** biome-ignore-all lint/suspicious/noExplicitAny: <_> */
|
||||||
import { ofetch } from 'ofetch'
|
|
||||||
import { $backendUrl, $requestRetries, $requestRetryCodes } from '../../../../configs/config.api'
|
|
||||||
import { $tokenExpiration, $tokenName } from '../../../../configs/config.security'
|
|
||||||
import { encryptRsa } from '../../scripts'
|
|
||||||
|
|
||||||
const URL = $backendUrl.get()
|
import dayjs from "dayjs";
|
||||||
const TOKEN_NAME = $tokenName.get()
|
import * as fs from "node:fs";
|
||||||
const TOKEN_EXPIRATION = $tokenExpiration.get()
|
import { ofetch } from "ofetch";
|
||||||
const RETRY = $requestRetries.get()
|
import * as toml from "toml";
|
||||||
const CODES = $requestRetryCodes.get()
|
import { encryptRsa } from "../../scripts/index.ts";
|
||||||
|
|
||||||
export default async (api: string, body: Object) => {
|
const apiConfig = toml.parse(
|
||||||
const today = new Date()
|
fs.readFileSync("configs/config.api.toml", "utf-8"),
|
||||||
const todayUnix = dayjs(today).unix()
|
);
|
||||||
const expiration = todayUnix + TOKEN_EXPIRATION
|
const securityConfig = toml.parse(
|
||||||
const aes = await encryptRsa(`${api.toString()}-${todayUnix.toString()}-${expiration.toString()}`)
|
fs.readFileSync("configs/config.security.toml", "utf-8"),
|
||||||
|
);
|
||||||
|
|
||||||
const hash = `${TOKEN_NAME}=${aes}token`
|
const TOKEN_NAME = securityConfig.token.token_name;
|
||||||
|
const TOKEN_EXPIRATION = securityConfig.token.token_expiration;
|
||||||
|
const URL = apiConfig.backend.backend_url;
|
||||||
|
const RETRY = apiConfig.request.request_retries;
|
||||||
|
const CODES = apiConfig.request.request_retry_codes;
|
||||||
|
|
||||||
|
export default async (api: string, body: { [key: string]: unknown }) => {
|
||||||
|
const today = new Date();
|
||||||
|
const todayUnix = dayjs(today).unix();
|
||||||
|
const expiration = todayUnix + TOKEN_EXPIRATION;
|
||||||
|
const aes = await encryptRsa(
|
||||||
|
`${api.toString()}-${todayUnix.toString()}-${expiration.toString()}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
const hash = `${TOKEN_NAME}=${aes}token`;
|
||||||
try {
|
try {
|
||||||
await ofetch(URL + api, {
|
await ofetch(URL + api, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: "application/json",
|
||||||
'Cache-Control': 'no-cache',
|
"Cache-Control": "no-cache",
|
||||||
'Dasig-Token': hash,
|
"Dasig-Token": hash,
|
||||||
},
|
},
|
||||||
retry: RETRY,
|
retry: RETRY,
|
||||||
retryDelay: 500,
|
retryDelay: 500,
|
||||||
retryStatusCodes: CODES,
|
retryStatusCodes: CODES,
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
body: body,
|
body: body,
|
||||||
})
|
});
|
||||||
return true
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
|
/** biome-ignore-all lint/complexity/noUselessFragments: <_> */
|
||||||
|
import * as fs from "node:fs";
|
||||||
import { type JSXElement, Show } from "solid-js";
|
import { type JSXElement, Show } from "solid-js";
|
||||||
import { $fontSource } from "../../configs/config.site.ts";
|
import * as toml from 'toml';
|
||||||
import background1 from "../images/background.avif";
|
import background1 from "../images/background.avif";
|
||||||
import background2 from "../images/background.webp";
|
import background2 from "../images/background.webp";
|
||||||
import "../styles/HTML.sass";
|
import "../styles/HTML.sass";
|
||||||
|
|
@ -22,6 +24,7 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (props: Props) => {
|
export default (props: Props) => {
|
||||||
|
const config = toml.parse(fs.readFileSync('configs/config.site.toml', 'utf8'))
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
@ -40,7 +43,7 @@ export default (props: Props) => {
|
||||||
<meta property="og:description" content={props.description} />
|
<meta property="og:description" content={props.description} />
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/favicon.png" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.png" />
|
||||||
<Show when={$fontSource.get() === "cdn"}>
|
<Show when={config.font.source === "cdn"}>
|
||||||
<link rel="preconnect" href="https://cdn.jsdelivr.net" />
|
<link rel="preconnect" href="https://cdn.jsdelivr.net" />
|
||||||
</Show>
|
</Show>
|
||||||
<Show when={props.preloadBackground}>
|
<Show when={props.preloadBackground}>
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
.SILENT:
|
.SILENT:
|
||||||
|
|
||||||
all:
|
all:
|
||||||
deno install && deno install --allow-scripts=npm:sharp,npm:@parcel/watcher
|
bun install && bun pm trust --all
|
||||||
|
|
||||||
dev:
|
dev:
|
||||||
deno task dev
|
bun run dev
|
||||||
|
|
||||||
build:
|
build:
|
||||||
deno task build && PORT=9000 deno run --allow-env --allow-read --allow-net .output/server/index.mjs &
|
bun run build && PORT=9000 node .output/server/index.mjs &
|
||||||
|
|
||||||
update:
|
update:
|
||||||
deno update
|
bun update
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
|
|
||||||
1389
frontend/bun.lock
Normal file
1389
frontend/bun.lock
Normal file
File diff suppressed because it is too large
Load diff
6
frontend/configs/config.api.toml
Normal file
6
frontend/configs/config.api.toml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
[backend]
|
||||||
|
backend_url = "http://localhost:8080"
|
||||||
|
|
||||||
|
[request]
|
||||||
|
request_retries = 3
|
||||||
|
request_retry_codes = [400, 404, 405, 500, 502]
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
import { atom } from 'nanostores'
|
|
||||||
|
|
||||||
export const $backendUrl = atom('http://localhost:8080')
|
|
||||||
|
|
||||||
export const $requestRetries = atom<number>(3)
|
|
||||||
export const $requestRetryCodes = atom<Array<number>>([400, 404, 405, 500, 502])
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import { atom } from 'nanostores'
|
[token]
|
||||||
|
token_name = "dasig" # output: dasig-token
|
||||||
|
token_encryption = "rsa"
|
||||||
|
token_expiration = 9 # seconds
|
||||||
|
|
||||||
export const $tokenName = atom<string>('dasig') // output: dasig-token
|
[rsa]
|
||||||
export const $tokenEncryption = atom<'rsa'>('rsa')
|
rsa_public_key = '''-----BEGIN PUBLIC KEY-----
|
||||||
export const $tokenExpiration = atom<number>(9) // expires in 9 seconds
|
|
||||||
|
|
||||||
export const $rsaPublicKey = atom<string>(`-----BEGIN PUBLIC KEY-----
|
|
||||||
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA9Aw5Zasdanf2biS69qoQ
|
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA9Aw5Zasdanf2biS69qoQ
|
||||||
/YZbyIM+LS7LOLNN3ot6nZH1FiTqTNy61ffUA2Y/s3hGz9L0+k6gRu7uGBza6XPU
|
/YZbyIM+LS7LOLNN3ot6nZH1FiTqTNy61ffUA2Y/s3hGz9L0+k6gRu7uGBza6XPU
|
||||||
+iuGdXxZd2mc3lrnPfR6SSllMwGlAVkYpQhmkB19igd8aLUbFiJ3pPKkNocv/yQa
|
+iuGdXxZd2mc3lrnPfR6SSllMwGlAVkYpQhmkB19igd8aLUbFiJ3pPKkNocv/yQa
|
||||||
|
|
@ -17,4 +17,4 @@ HvEuAHzUBr+GJM9w4/LF1mQSsmblB8q5S7qNaminYAw6wm35lRy7ZlIbJQlj/EyL
|
||||||
lCKWBbUEHkjzRFCoun9VVUc0guQTsTbchPD7Rgzg3SBK3Gws39n12WQPc7jKto0H
|
lCKWBbUEHkjzRFCoun9VVUc0guQTsTbchPD7Rgzg3SBK3Gws39n12WQPc7jKto0H
|
||||||
N39sJnNzllXw41gKRy9b2uYuaVYaQ0sjrFJ8ITuyO9NDDaEdeBqBBTtbRp2i0O4K
|
N39sJnNzllXw41gKRy9b2uYuaVYaQ0sjrFJ8ITuyO9NDDaEdeBqBBTtbRp2i0O4K
|
||||||
tvT2kItEEnVzjNutUatVOWcCAwEAAQ==
|
tvT2kItEEnVzjNutUatVOWcCAwEAAQ==
|
||||||
-----END PUBLIC KEY-----`)
|
-----END PUBLIC KEY-----'''
|
||||||
11
frontend/configs/config.site.toml
Normal file
11
frontend/configs/config.site.toml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
[website]
|
||||||
|
name = "Dasig"
|
||||||
|
description = "An architectural framework for pure speed fullstack development"
|
||||||
|
|
||||||
|
[font]
|
||||||
|
name = "inter"
|
||||||
|
source = "cdn" # cdn or local
|
||||||
|
|
||||||
|
[copyright]
|
||||||
|
name = "Pat Alcala"
|
||||||
|
year = 2025
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
import { atom } from 'nanostores'
|
|
||||||
|
|
||||||
export const $websiteName = atom<string>('Dasig')
|
|
||||||
export const $websiteDescription = atom<string>('A template for next level speed (Solid Version)')
|
|
||||||
|
|
||||||
export const $font = atom<string>('inter')
|
|
||||||
export const $fontSource = atom<'cdn'| 'local'>('cdn')
|
|
||||||
|
|
||||||
export const $companyName = atom<string>('Pat Alcala')
|
|
||||||
export const $copyRightYear = atom<number>(2025)
|
|
||||||
3922
frontend/deno.lock
generated
3922
frontend/deno.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -13,14 +13,13 @@
|
||||||
"@solidjs/start": "^1.1.0",
|
"@solidjs/start": "^1.1.0",
|
||||||
"consola": "^3.4.2",
|
"consola": "^3.4.2",
|
||||||
"dayjs": "^1.11.19",
|
"dayjs": "^1.11.19",
|
||||||
"eciesjs": "^0.4.16",
|
|
||||||
"jsencrypt": "^3.5.4",
|
"jsencrypt": "^3.5.4",
|
||||||
"nanostores": "^1.1.0",
|
"nanostores": "^1.1.0",
|
||||||
"ofetch": "^1.5.1",
|
"ofetch": "^1.5.1",
|
||||||
"png-to-ico": "^3.0.1",
|
|
||||||
"sharp": "^0.34.5",
|
"sharp": "^0.34.5",
|
||||||
"solid-icons": "^1.1.0",
|
"solid-icons": "^1.1.0",
|
||||||
"solid-js": "^1.9.10",
|
"solid-js": "^1.9.10",
|
||||||
|
"toml": "^3.0.0",
|
||||||
"vinxi": "^0.5.7",
|
"vinxi": "^0.5.7",
|
||||||
"yargs": "^18.0.0"
|
"yargs": "^18.0.0"
|
||||||
},
|
},
|
||||||
|
|
@ -31,5 +30,8 @@
|
||||||
"@biomejs/biome": "^2.3.7",
|
"@biomejs/biome": "^2.3.7",
|
||||||
"@types/node": "^24.10.1",
|
"@types/node": "^24.10.1",
|
||||||
"sass-embedded": "^1.93.3"
|
"sass-embedded": "^1.93.3"
|
||||||
}
|
},
|
||||||
|
"trustedDependencies": [
|
||||||
|
"@parcel/watcher"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,29 @@
|
||||||
// deno-lint-ignore-file jsx-no-children-prop
|
// deno-lint-ignore-file jsx-no-children-prop
|
||||||
import { createHandler, StartServer } from '@solidjs/start/server';
|
|
||||||
import { HTML } from '../@dasig/index.ts';
|
|
||||||
import { $companyName, $font, $websiteDescription, $websiteName } from '../configs/config.site.ts';
|
|
||||||
|
|
||||||
const websiteName = $websiteName.get()
|
import * as fs from "node:fs";
|
||||||
const websiteDescription = $websiteDescription.get()
|
// import { $companyName, $font, $websiteDescription, $websiteName } from '../configs/config.site.ts';
|
||||||
const author = $companyName.get()
|
import { createHandler, StartServer } from "@solidjs/start/server";
|
||||||
const font = $font.get()
|
import * as toml from "toml";
|
||||||
|
import { HTML } from "../@dasig/index.ts";
|
||||||
|
|
||||||
export default createHandler(() => <StartServer document={({ assets, children, scripts }) => <HTML name={websiteName} description={websiteDescription} author={author} children={children} assets={assets} scripts={scripts} font={font} />} />)
|
const config = toml.parse(fs.readFileSync("configs/config.site.toml", "utf8"));
|
||||||
|
const websiteName = config.website.name;
|
||||||
|
const websiteDescription = config.website.description;
|
||||||
|
const author = config.copyright.name;
|
||||||
|
const font = config.font.name;
|
||||||
|
|
||||||
|
export default createHandler(() => (
|
||||||
|
<StartServer
|
||||||
|
document={({ assets, children, scripts }) => (
|
||||||
|
<HTML
|
||||||
|
name={websiteName}
|
||||||
|
description={websiteDescription}
|
||||||
|
author={author}
|
||||||
|
children={children}
|
||||||
|
assets={assets}
|
||||||
|
scripts={scripts}
|
||||||
|
font={font}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue