Skip to content
This repository was archived by the owner on May 10, 2025. It is now read-only.

Commit f19f0f6

Browse files
committed
feat: render route
1 parent 38248e4 commit f19f0f6

17 files changed

Lines changed: 3033 additions & 11 deletions

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
HOST="0.0.0.0"
2+
PORT=8080
3+
TIMEOUT=0
4+
WAIT_FOR_PAGE_LOAD_TIMEOUT=2000
5+
REVERSE_PROXY=false

.eslintrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
7+
"parser": "@typescript-eslint/parser",
8+
"parserOptions": {
9+
"ecmaVersion": "latest",
10+
"sourceType": "module"
11+
},
12+
"plugins": ["@typescript-eslint"],
13+
"rules": {}
14+
}

.github/workflows/build.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: build-check
2+
on: pull_request
3+
jobs:
4+
build-check:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Checkout code
8+
uses: actions/checkout@v2
9+
10+
- name: Set up Node.js
11+
uses: actions/setup-node@v2
12+
with:
13+
node-version: '18'
14+
15+
- name: Install dependencies
16+
run: npm install
17+
18+
- name: Start build
19+
run: npm run build

.github/workflows/deploy.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
name: Create and publish a Docker image
3+
4+
# Configures this workflow to run every time a change is pushed to the branch called `release`.
5+
on:
6+
release:
7+
types:
8+
- published
9+
10+
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
16+
jobs:
17+
build-and-push-image:
18+
runs-on: ubuntu-latest
19+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
20+
permissions:
21+
contents: read
22+
packages: write
23+
#
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v3
27+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
28+
- name: Log in to the Container registry
29+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
35+
- name: Extract metadata (tags, labels) for Docker
36+
id: meta
37+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
41+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
42+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
43+
- name: Build and push Docker image
44+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
45+
with:
46+
context: .
47+
push: true
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/format-check.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: format-check
2+
on: pull_request
3+
jobs:
4+
format-check:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Checkout code
8+
uses: actions/checkout@v2
9+
10+
- name: Set up Node.js
11+
uses: actions/setup-node@v2
12+
with:
13+
node-version: '18'
14+
15+
- name: Install dependencies
16+
run: npm install
17+
18+
- name: Check formatting
19+
run: npm run format:check

.gitignore

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,164 @@
11
# Logs
2+
23
logs
3-
*.log
4-
npm-debug.log*
4+
_.log
5+
npm-debug.log_
56
yarn-debug.log*
67
yarn-error.log*
78
lerna-debug.log*
89
.pnpm-debug.log*
910

1011
# Diagnostic reports (https://nodejs.org/api/report.html)
11-
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
1214

1315
# Runtime data
16+
1417
pids
15-
*.pid
16-
*.seed
17-
*.pid.lock
18+
_.pid
19+
_.seed
20+
\*.pid.lock
1821

1922
# Directory for instrumented libs generated by jscoverage/JSCover
23+
2024
lib-cov
2125

2226
# Coverage directory used by tools like istanbul
27+
2328
coverage
24-
*.lcov
29+
\*.lcov
2530

2631
# nyc test coverage
32+
2733
.nyc_output
2834

2935
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
36+
3037
.grunt
3138

3239
# Bower dependency directory (https://bower.io/)
40+
3341
bower_components
3442

3543
# node-waf configuration
44+
3645
.lock-wscript
3746

3847
# Compiled binary addons (https://nodejs.org/api/addons.html)
48+
3949
build/Release
4050

4151
# Dependency directories
52+
4253
node_modules/
4354
jspm_packages/
4455

4556
# Snowpack dependency directory (https://snowpack.dev/)
57+
4658
web_modules/
4759

4860
# TypeScript cache
49-
*.tsbuildinfo
61+
62+
\*.tsbuildinfo
5063

5164
# Optional npm cache directory
65+
5266
.npm
5367

5468
# Optional eslint cache
69+
5570
.eslintcache
5671

5772
# Optional stylelint cache
73+
5874
.stylelintcache
5975

6076
# Microbundle cache
77+
6178
.rpt2_cache/
6279
.rts2_cache_cjs/
6380
.rts2_cache_es/
6481
.rts2_cache_umd/
6582

6683
# Optional REPL history
84+
6785
.node_repl_history
6886

6987
# Output of 'npm pack'
70-
*.tgz
88+
89+
\*.tgz
7190

7291
# Yarn Integrity file
92+
7393
.yarn-integrity
7494

7595
# dotenv environment variable files
96+
7697
.env
7798
.env.development.local
7899
.env.test.local
79100
.env.production.local
80101
.env.local
81102

82103
# parcel-bundler cache (https://parceljs.org/)
104+
83105
.cache
84106
.parcel-cache
85107

86108
# Next.js build output
109+
87110
.next
88111
out
89112

90113
# Nuxt.js build / generate output
114+
91115
.nuxt
92116
dist
93117

94118
# Gatsby files
119+
95120
.cache/
121+
96122
# Comment in the public line in if your project uses Gatsby and not Next.js
123+
97124
# https://nextjs.org/blog/next-9-1#public-directory-support
125+
98126
# public
99127

100128
# vuepress build output
129+
101130
.vuepress/dist
102131

103132
# vuepress v2.x temp and cache directory
133+
104134
.temp
105135
.cache
106136

107137
# Serverless directories
138+
108139
.serverless/
109140

110141
# FuseBox cache
142+
111143
.fusebox/
112144

113145
# DynamoDB Local files
146+
114147
.dynamodb/
115148

116149
# TernJS port file
150+
117151
.tern-port
118152

119153
# Stores VSCode versions used for testing VSCode extensions
154+
120155
.vscode-test
121156

122157
# yarn v2
158+
123159
.yarn/cache
124160
.yarn/unplugged
125161
.yarn/build-state.yml
126162
.yarn/install-state.gz
127-
.pnp.*
163+
.pnp.\*
164+

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
4+
"singleQuote": true
5+
}

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM node:18-alpine as build
2+
WORKDIR /app
3+
COPY . .
4+
RUN npm install
5+
RUN npm run build
6+
7+
FROM node:18-alpine as run
8+
WORKDIR /app
9+
COPY --from=build /app/dist/ /app/package*.json ./
10+
RUN npm install --omit=dev
11+
CMD npm run start:docker
12+
EXPOSE 8080

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
11
# webder
2-
Http/s proxy that render pages with js and returns HTML
2+
3+
Http/s proxy that render pages with js and returns HTML
4+
5+
> [!WARNING]
6+
> This service is not purify html and not blocking XSS attacks. Also it is not block requests to localhost, etc.
7+
> This is not intended to be used as a user-facing browser. Use it ONLY for making api calls from other services, make sure to run it behind a firewall and use a reverse proxy in front of it.
8+
9+
## Features
10+
11+
- Render pages with js (/render?url=...)
12+
13+
## Usage
14+
15+
For env variables look to `.env.example`. Docker also supported.
16+
17+
```bash
18+
npm install
19+
npm run build
20+
npm start
21+
```

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "3"
2+
3+
services:
4+
txtdot:
5+
image: ghcr.io/txtdot/webder:latest
6+
ports:
7+
- "8080:8080"
8+
restart: unless-stopped
9+
volumes:
10+
- ".env:/app/.env"

0 commit comments

Comments
 (0)