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
// Do enable nodejs_compat | |
// https://developers.cloudflare.com/workers/runtime-apis/nodejs/ | |
import crypto from 'node:crypto' | |
import { Context, Hono } from 'hono' | |
const app = new Hono() | |
function generateJWT(payload, secret, expiresIn) { | |
const header = { alg: 'HS256', typ: 'JWT' } | |
const encodedHeader = base64UrlEncode(JSON.stringify(header)) |
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
const fs = require("fs"); | |
const path = require("path"); | |
const https = require("https"); | |
var ImageKit = require("imagekit"); | |
const projectId = ""; | |
var imagekit = new ImageKit({ | |
publicKey: "", | |
privateKey: "", |
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
import os, re, requests, shutil, asyncio, time, aiohttp | |
root = next(os.walk('.'))[1] | |
root.remove('.git') | |
pattern = r'https?://(?:[^\s()<>{}\[\]]+\.(?:jpg|jpeg|gif|png))(?![^\s]*\))' | |
async def get(url, session): | |
try: | |
async with session.get(url=url) as response: |
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
const { data } = require("./data"); | |
const StoryblokClient = require("storyblok-js-client"); | |
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | |
const Storyblok = new StoryblokClient({ | |
oauthToken: "", | |
}); | |
const spaceId = 164462; |
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 was added by layer0 init. | |
// You should commit this file to source control. | |
require('dotenv').config() | |
const { Router, CustomCacheKey } = require('@layer0/core/router') | |
const { nuxtRoutes } = require('@layer0/nuxt') | |
const homeRedirect = require('./faas/home-redirect.js') | |
const clearCache = require('./faas/clear-cache.js') | |
const sitemap = require('./faas/sitemap.js') |
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
<script> | |
// Check that service workers are supported | |
if ('serviceWorker' in navigator) { | |
// Use the window load event to keep the page load performant | |
window.addEventListener('load', () => { | |
navigator.serviceWorker.register('/service-worker.js'); | |
}); | |
} | |
</script> |
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
npx workbox-cli injectManifest && node compile_sw.js |
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
const { build } = require("esbuild") | |
build({ | |
entryPoints: ["./path/to/service-worker.js"], | |
outfile: "./dist/service-worker.js", | |
minify: true, | |
bundle: true, | |
define: { | |
'process.env.NODE_ENV': '"production"', | |
'process.env.SOME_VARIABLE': '"SOME_VALUE"' |
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
module.exports = { | |
globDirectory: "dist/", | |
globPatterns: [ | |
"**/*.{css,eot,html,ico,jpg,js,json,png,svg,ttf,txt,webmanifest,woff,woff2,webm,xml}", | |
], | |
globFollow: true, | |
globStrict: true, | |
globIgnores: [ | |
"**/*-es5.*.js", | |
"3rdpartylicenses.txt", |
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
const express = require('express') | |
const app = express() | |
app.use(express.json()) | |
app.all('/api/some-route/:slug.json', (req, res) => { | |
const slug = req.params.slug | |
// some data fetching calls from the slug | |
res.json({ data: 'data' }) | |
}) |
NewerOlder