-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
309 additions
and
441 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.lockb binary diff=lockb |
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,13 @@ | ||
name: Bun | ||
on: [push] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
name: Bun | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: oven-sh/setup-bun@v2 | ||
with: | ||
bun-version: latest | ||
- run: bun install --frozen-lockfile | ||
- run: bun run lint |
This file was deleted.
Oops, something went wrong.
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 +1,3 @@ | ||
|
||
.DS_Store | ||
.vscode | ||
node_modules |
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 @@ | ||
{ "prettier": true, "ignores": ["app/index.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,39 @@ | ||
# Based on https://github.com/denoland/deno_docker/blob/main/alpine.dockerfile | ||
# syntax = docker/dockerfile:1 | ||
|
||
ARG BIN_IMAGE=denoland/deno:bin | ||
FROM ${BIN_IMAGE} AS bin | ||
# Adjust BUN_VERSION as desired | ||
ARG BUN_VERSION=1.1.22 | ||
FROM oven/bun:${BUN_VERSION}-slim as base | ||
|
||
FROM frolvlad/alpine-glibc:alpine-3.13 | ||
LABEL fly_launch_runtime="Bun" | ||
|
||
RUN apk --no-cache add ca-certificates | ||
# Bun app lives here | ||
WORKDIR /app | ||
|
||
RUN addgroup --gid 1000 deno \ | ||
&& adduser --uid 1000 --disabled-password deno --ingroup deno \ | ||
&& mkdir /deno-dir/ \ | ||
&& chown deno:deno /deno-dir/ | ||
# Set production environment | ||
ENV NODE_ENV="production" | ||
|
||
ENV DENO_DIR /deno-dir/ | ||
ENV DENO_INSTALL_ROOT /usr/local | ||
|
||
ARG DENO_VERSION | ||
ENV DENO_VERSION=${DENO_VERSION} | ||
COPY --from=bin /deno /bin/deno | ||
# Throw-away build stage to reduce size of final image | ||
FROM base as build | ||
|
||
WORKDIR /deno-dir | ||
COPY . . | ||
# Install packages needed to build node modules | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y build-essential pkg-config python-is-python3 | ||
|
||
ENTRYPOINT ["/bin/deno"] | ||
CMD ["run", "--allow-net", "https://deno.land/std/examples/echo_server.ts"] | ||
# Install node modules | ||
COPY --link bun.lockb package.json ./ | ||
RUN bun install --production | ||
|
||
# Copy application code | ||
COPY --link . . | ||
|
||
|
||
# Final stage for app image | ||
FROM base | ||
|
||
# Copy built application | ||
COPY --from=build /app /app | ||
|
||
# Start the server by default, this can be overwritten at runtime | ||
EXPOSE 8080 | ||
CMD [ "bun", "source/app.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
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,14 @@ | ||
{ | ||
"dependencies": { | ||
"@oakserver/oak": "^14.1.0", | ||
"simple-icons": "^13.5.0", | ||
"svg-path-commander": "^2.0.9" | ||
}, | ||
"devDependencies": { | ||
"xo": "^0.59.3" | ||
}, | ||
"scripts": { | ||
"start": "bun source/app.js", | ||
"lint": "xo" | ||
} | ||
} |
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,49 +1,47 @@ | ||
import { getIconSvg, getSimpleIcon } from "./icon.js"; | ||
import { Application } from "jsr:@oak/oak/application"; | ||
import { Router } from "jsr:@oak/oak/router"; | ||
import {Application, Router} from '@oakserver/oak'; | ||
import {getIconSvg, getSimpleIcon} from './icon.js'; | ||
|
||
const router = new Router(); | ||
|
||
router.get("/", (ctx) => { | ||
ctx.response.headers.set( | ||
"Cache-Control", | ||
"public, max-age=86400, s-maxage=31536000, stale-while-revalidate=604800", | ||
); | ||
ctx.response.status = 307; | ||
ctx.response.redirect("https://github.com/LitoMore/simple-icons-cdn"); | ||
router.get('/', (context) => { | ||
context.response.headers.set( | ||
'Cache-Control', | ||
'public, max-age=86400, s-maxage=31536000, stale-while-revalidate=604800', | ||
); | ||
context.response.status = 307; | ||
context.response.redirect('https://github.com/LitoMore/simple-icons-cdn'); | ||
}); | ||
router.get("/favicon.ico", (ctx) => { | ||
ctx.response.headers.set( | ||
"Cache-Control", | ||
"public, max-age=31536000, s-maxage=31536000, immutable", | ||
); | ||
ctx.response.status = 204; | ||
router.get('/favicon.ico', (context) => { | ||
context.response.headers.set( | ||
'Cache-Control', | ||
'public, max-age=31536000, s-maxage=31536000, immutable', | ||
); | ||
context.response.status = 204; | ||
}); | ||
router.get("/:iconSlug/:color?/:darkModeColor?", (ctx) => { | ||
ctx.response.headers.set("Access-Control-Allow-Origin", "*"); | ||
ctx.response.headers.set( | ||
"Cache-Control", | ||
"public, max-age=86400, s-maxage=31536000, stale-while-revalidate=604800", | ||
); | ||
router.get('/:iconSlug/:color?/:darkModeColor?', (context) => { | ||
context.response.headers.set('Access-Control-Allow-Origin', '*'); | ||
context.response.headers.set( | ||
'Cache-Control', | ||
'public, max-age=86400, s-maxage=31536000, stale-while-revalidate=604800', | ||
); | ||
|
||
const { iconSlug, color, darkModeColor } = ctx.params; | ||
const viewbox = ctx.request.url.searchParams.get("viewbox"); | ||
const icon = getSimpleIcon(iconSlug); | ||
const {iconSlug, color, darkModeColor} = context.params; | ||
const viewbox = context.request.url.searchParams.get('viewbox'); | ||
const icon = getSimpleIcon(iconSlug); | ||
|
||
if (icon) { | ||
const iconSvg = getIconSvg(icon, color, darkModeColor, viewbox); | ||
ctx.response.headers.set("Content-Type", "image/svg+xml"); | ||
ctx.response.body = iconSvg; | ||
return; | ||
} | ||
if (icon) { | ||
const iconSvg = getIconSvg(icon, color, darkModeColor, viewbox); | ||
context.response.headers.set('Content-Type', 'image/svg+xml'); | ||
context.response.body = iconSvg; | ||
return; | ||
} | ||
|
||
ctx.response.status = 404; | ||
return; | ||
context.response.status = 404; | ||
}); | ||
|
||
const app = new Application(); | ||
app.use(router.routes()); | ||
app.use(router.allowedMethods()); | ||
app.listen({ port: 8080 }); | ||
app.listen({port: 8080}); | ||
|
||
console.log("Server running at http://localhost:8080/simpleicons"); | ||
console.log('Server running at http://localhost:8080/simpleicons'); |
Oops, something went wrong.