Skip to content

Commit

Permalink
Merge pull request #12 from zisra/dev
Browse files Browse the repository at this point in the history
(refactor): Use Nitro web server
  • Loading branch information
binaryoverload authored Sep 13, 2023
2 parents f2d4e52 + e6000b3 commit d42c5d6
Show file tree
Hide file tree
Showing 22 changed files with 5,949 additions and 2,431 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
*.log*
.nitro
.cache
.output
.env
dist
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
.output
node-modules
50 changes: 50 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {
env: {
browser: true,
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
],
ignorePatterns: ["public/*", "dist/*", "/*.js", "/*.ts"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: "./",
},
settings: {
"import/resolver": {
typescript: {
project: "./tsconfig.json",
},
},
},
plugins: ["@typescript-eslint", "import", "prettier"],
rules: {
"no-underscore-dangle": "off",
"@typescript-eslint/no-explicit-any": "off",
"no-console": "off",
"@typescript-eslint/no-this-alias": "off",
"import/prefer-default-export": "off",
"@typescript-eslint/no-empty-function": "off",
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"],
"no-restricted-syntax": "off",
"import/no-unresolved": ["error", { ignore: ["^virtual:"] }],
"consistent-return": "off",
"no-continue": "off",
"no-eval": "off",
"no-await-in-loop": "off",
"no-nested-ternary": "off",
"prefer-destructuring": "off",
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"import/extensions": [
"error",
"ignorePackages",
{
ts: "never",
tsx: "never",
},
]
},
}
18 changes: 0 additions & 18 deletions .eslintrc.json

This file was deleted.

60 changes: 0 additions & 60 deletions .github/workflows/build_release.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Linting and Testing

on:
push:
branches:
- master
- dev
pull_request:

jobs:
linting:
name: Run Linters
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install npm packages
run: npm install

- name: Prepare for linting
run: npm run prepare

- name: Run ESLint
run: npm run lint

building:
name: Build project
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install npm packages
run: npm install

- name: Build Project
run: npm run build
42 changes: 0 additions & 42 deletions .github/workflows/linting_testing.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Docker Publish

on:
push:
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

- name: Get version
id: package-version
uses: martinbeentjes/npm-get-version-action@main

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=auto
tags: |
type=semver,pattern={{version}},value=v${{ steps.package-version.outputs.current-version }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
push: true
context: .
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release

on:
push:
branches:
- master

jobs:
release:
name: Release
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Get version
id: package-version
uses: martinbeentjes/npm-get-version-action@main

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.package-version.outputs.current-version }}
release_name: Bot v${{ steps.package-version.outputs.current-version }}
draft: false
prerelease: false
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
node_modules
dist
*.log*
.nitro
.cache
.output
.env
dist
5 changes: 1 addition & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig"
]
"recommendations": ["dbaeumer.vscode-eslint", "editorconfig.editorconfig"]
}
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:18-alpine as base
WORKDIR /app

# Build layer
FROM base as build

COPY package-lock.json package.json ./
RUN npm install --frozen-lockfile
COPY . .
RUN npm run build

# Production layer
FROM base as production

EXPOSE 3000
ENV NODE_ENV=production
COPY --from=build /app/.output ./.output

CMD ["node", ".output/server/index.mjs"]
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Cloudflare worker proxy
# simple-proxy

Simple http proxy in a cloudflare worker.
Simple reverse proxy to bypass CORS, used by [movie-web](https://movie-web.app).

features:
- Deployable on many platforms - thanks to nitro
- header rewrites - read and write protected headers
- bypass CORS - always allows browser to send requests through it

supported platforms:
- cloudflare workers
- nodejs

## Todos:
- [ ] release with multi platform
- [ ] Easy deploy to cloudflare button (just needs CI)
- [ ] Test on cloudflare
5 changes: 5 additions & 0 deletions nitro.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//https://nitro.unjs.io/config
export default defineNitroConfig({
noPublicDir: true,
srcDir: "./src"
});
Loading

0 comments on commit d42c5d6

Please sign in to comment.