mirror of
https://github.com/BradNut/awesome-uses
synced 2025-09-08 17:40:31 +00:00
server WIP
This commit is contained in:
parent
5a9913ce77
commit
6fc2c74f25
5 changed files with 6057 additions and 49 deletions
|
|
@ -32,6 +32,7 @@
|
||||||
"country-emoji": "^1.5.6",
|
"country-emoji": "^1.5.6",
|
||||||
"isbot": "^3.6.6",
|
"isbot": "^3.6.6",
|
||||||
"joi": "^17.8.1",
|
"joi": "^17.8.1",
|
||||||
|
"netlify-cli": "^13.0.0",
|
||||||
"normalize.css": "^8.0.1",
|
"normalize.css": "^8.0.1",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
|
|
@ -42,9 +43,8 @@
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^4.9.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "remix build",
|
"build": "netlify build",
|
||||||
"dev": "NODE_ENV=development remix dev",
|
"dev": "NODE_ENV=development remix dev"
|
||||||
"start": "remix start"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/styled-components": "^5.1.26",
|
"@types/styled-components": "^5.1.26",
|
||||||
|
|
|
||||||
6075
pnpm-lock.yaml
6075
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +1,7 @@
|
||||||
const { config } = require("@netlify/remix-edge-adapter");
|
const { config } = require("@netlify/remix-edge-adapter");
|
||||||
/** @type {import('@remix-run/dev').AppConfig} */
|
/** @type {import('@remix-run/dev').AppConfig} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...config,
|
...(process.env.NETLIFY || process.env.NETLIFY_LOCAL ? config : {}),
|
||||||
appDirectory: "src",
|
appDirectory: "src",
|
||||||
future: {
|
future: {
|
||||||
unstable_postcss: true,
|
unstable_postcss: true,
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,9 @@ export default async function handleRequest(
|
||||||
) {
|
) {
|
||||||
// check if we have a cached response in memory
|
// check if we have a cached response in memory
|
||||||
const cachedResponse = cache.get(request.url);
|
const cachedResponse = cache.get(request.url);
|
||||||
if (cachedResponse) {
|
const isBuildUrl = request.url.includes('/build/');
|
||||||
console.log('Serving from cache', request.url);
|
if (cachedResponse && !isBuildUrl) {
|
||||||
|
// console.log('Serving from cache', request.url);
|
||||||
// if we have a cached response, check if it's less than 5 seconds old
|
// if we have a cached response, check if it's less than 5 seconds old
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const diff = now.getTime() - cachedResponse.date.getTime();
|
const diff = now.getTime() - cachedResponse.date.getTime();
|
||||||
|
|
@ -63,13 +64,15 @@ export default async function handleRequest(
|
||||||
// tee the stream so we can cache it and send it to the client
|
// tee the stream so we can cache it and send it to the client
|
||||||
const [toReponse, toCache] = body.tee();
|
const [toReponse, toCache] = body.tee();
|
||||||
|
|
||||||
|
if (!isBuildUrl) {
|
||||||
streamToText(toCache).then(html => {
|
streamToText(toCache).then(html => {
|
||||||
console.log('Caching', request.url);
|
console.log('Caching', request.url);
|
||||||
cache.set(request.url, {
|
cache.set(request.url, {
|
||||||
html: html.replace('Rendered Fresh',`Rendered from cache ${new Date().toISOString()}`),
|
html: html.replace('Rendered Fresh', `Rendered from cache ${new Date().toISOString()}`),
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const headers = new Headers(responseHeaders);
|
const headers = new Headers(responseHeaders);
|
||||||
headers.set("Content-Type", "text/html");
|
headers.set("Content-Type", "text/html");
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,10 @@ body::-webkit-scrollbar-thumb {
|
||||||
grid-template-rows: 1fr auto auto;
|
grid-template-rows: 1fr auto auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.PersonWrapper:nth-child(5) {
|
||||||
|
background: green;
|
||||||
|
}
|
||||||
|
|
||||||
.PersonInner {
|
.PersonInner {
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue