Skip to content

Commit

Permalink
Merge pull request #2 from kiwilan/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ewilan-riviere authored Oct 4, 2023
2 parents ae6fda1 + 1d38247 commit 59dbae5
Show file tree
Hide file tree
Showing 42 changed files with 1,560 additions and 959 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
PORT=3000
HOST=0.0.0.0
HOST=localhost
HTTPS=false
ENV=development # development, production, test
TOKEN=123456789 # generate with `openssl rand -hex 12`
DOCKER_COMPOSE_PORT=3000 # only used with docker-compose
3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ screen*.png
/src/public/downloads
/coverage
feedrender.db
/data
7 changes: 3 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ stages:
- deploy

variables:
NODE_VERSION: "18.17.0"
NODE_VERSION: 18.17.0

deploy-job:
stage: deploy
image: alpine:latest
before_script:
- "command -v ssh-agent >/dev/null || ( apk add --update openssh )"
- 'command -v ssh-agent >/dev/null || ( apk add --update openssh )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
Expand All @@ -28,10 +28,9 @@ deploy-job:
git pull &&
/home/$SSH_USER/.nvm/versions/node/v$NODE_VERSION/bin/pnpm i &&
/home/$SSH_USER/.nvm/versions/node/v$NODE_VERSION/bin/pnpm build &&
docker build -t feedrender-app:latest . &&
docker compose build --no-cache &&
docker compose down &&
docker compose up -d &&
docker image prune -f &&
notifier '$CI_PROJECT_TITLE deployed'"
only:
- main
39 changes: 39 additions & 0 deletions .vscode/old/supabase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// import type { SupabaseClient } from '@supabase/supabase-js'
// import { createClient } from '@supabase/supabase-js'

// type Table = 'users'

// export class Supabase {
// protected constructor(
// protected client: SupabaseClient,
// ) {}

// public static make(): Supabase {
// const dotenv = globalThis.dotenv()
// const client = createClient(dotenv.SUPABASE_URL!, dotenv.SUPABASE_KEY!, {
// auth: {
// persistSession: false,
// },
// })
// const self = new Supabase(client)

// return self
// }

// public async table(name: Table) {
// this.client.rpc('create_table', { name: 'cache', columns: ['id SERIAL PRIMARY KEY', 'url TEXT', 'token TEXT'] })

// const { error } = await this.client
// .from('countries')
// .insert({ name: 'United Kingdom' })

// console.error(error)
// }

// public async all(name: Table) {
// const { data, error } = await this.client.from('countries').select('*')

// console.error(error)
// console.error(data)
// }
// }
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
},
"eslint.validate": ["javascript", "js", "typescript"],
"typescript.tsdk": "node_modules/typescript/lib",
"dotenv.enableAutocloaking": false
"dotenv.enableAutocloaking": false,
"eslint.experimental.useFlatConfig": true
}
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ RUN apk add git
COPY . /usr/src/app/
RUN npm install -g pnpm
RUN pnpm install
RUN if [ -d "dist" ]; then echo dist/ exists ; else pnpm build ; fi
RUN pnpm build

ENV PORT=3000
ENV HOST=0.0.0.0
ENV HTTPS=false

EXPOSE 3000

CMD [ "pnpm", "start:tsx" ]
CMD [ "pnpm", "start" ]
45 changes: 35 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Feedrender

![Banner with microphone picture in background and Feedrender title](https://raw.githubusercontent.com/kiwilan/feedrender/main/docs/banner.jpg)

[![version][version-src]][version-href]
[![h3][h3-version-src]][h3-version-href]
[![node][node-version-src]][node-version-href]
Expand All @@ -22,7 +24,8 @@ Some podcast services offer a RSS feed with HTML render if RSS feed is requested
- 🔧 Option to return XML feed
- 🗂️ Option to return JSON response with HTML as string
- ✅ If crawler is not a browser, return original XML feed
- 🗄️ Return a JSON response with RSS feed parsed as objects on `/api/parser` endpoint
- 🗄️ Return a JSON response with RSS feed parsed as objects on `/api/json` endpoint
- 🗒️ Return a XML response with RSS feed on `/api/xml` endpoint

### Roadmap

Expand Down Expand Up @@ -53,22 +56,44 @@ Default behavior is to return HTML as page. You can use query parameters to chan

Query parameters

| Name | Required | Type | Default | Description |
| -------- | -------- | --------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `url` | true | `string` | `undefined` | URL of RSS feed, allow base64 URL |
| `format` | false | `html`, `json`, `xml` | `html` | Type of response, default `html` will render HTML page, `json` will give JSON response with HTML string and `xml` will give original RSS feed |
| Name | Required | Type | Default | Description |
| -------- | -------- | -------------- | ----------- | ------------------------------------------------------------------------------------------------------- |
| `url` | true | `string` | `undefined` | URL of RSS feed, allow base64 URL |
| `format` | false | `html`, `json` | `html` | Type of response, default `html` will render HTML page, `json` will give JSON response with HTML string |

> [!WARNING]\
> If crawler is not a browser, response will be original XML feed.
Example: <https://feedrender.git-projects.xyz/api/render?url=https://2hdp.fr/2HDP.xml>

### Parser
### JSON

To parse RSS feed, you can use the `/json` endpoint.

```bash
/api/json
```

Return a JSON response with `Podcast` object represent RSS feed.

Query parameters

To parse RSS feed, you can use the `/parser` endpoint.
| Name | Required | Type | Default | Description |
| ----- | -------- | -------- | ----------- | --------------------------------- |
| `url` | true | `string` | `undefined` | URL of RSS feed, allow base64 URL |

Example: <https://feedrender.git-projects.xyz/api/json?url=https://2hdp.fr/2HDP.xml>

### XML

To parse show XML from RSS feed, you can use the `/xml` endpoint.

> [!NOTE]\
>
> Could be useful for RSS feed with only HTML render.
```bash
/api/parser
/api/xml
```

Return a JSON response with `Podcast` object represent RSS feed.
Expand All @@ -79,7 +104,7 @@ Query parameters
| ----- | -------- | -------- | ----------- | --------------------------------- |
| `url` | true | `string` | `undefined` | URL of RSS feed, allow base64 URL |

Example: <https://feedrender.git-projects.xyz/api/parser?url=https://2hdp.fr/2HDP.xml>
Example: <https://feedrender.git-projects.xyz/api/xml?url=https://feedpress.me/rdvjeux>

## Installation

Expand Down Expand Up @@ -143,7 +168,7 @@ pnpm build
Local preview

```bash
pnpm start:tsx
pnpm start
```

You can use PM2 to run application in production.
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ services:
ports:
- '${DOCKER_COMPOSE_PORT}:${PORT}'
env_file: .env
volumes:
- sqlite-data:/usr/src/app/sqlite
restart: always

volumes:
sqlite-data:
Binary file added docs/feedrender.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dump.rdb
Binary file not shown.
15 changes: 15 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// eslint.config.js
import antfu from '@antfu/eslint-config'

export default antfu({
markdown: false,
ignores: [
'./.github/**/*',
'./.github/**/*.md',
'./.vscode/**/*',
],
rules: {
'no-console': 'warn',
'node/prefer-global/process': 'off',
},
})
34 changes: 22 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"homepage": "https://github.com/kiwilan/feedrender",
"main": "index.js",
"scripts": {
"start": "listhen --public=false ./dist/index.js",
"start:tsx": "tsx ./dist/node.js",
"dev": "listhen -w ./src/index.ts",
"start": "tsx ./dist/node.js",
"start:listhen": "listhen --public=false ./dist/index.js",
"dev": "tsx --watch ./src/node.ts",
"dev:listhen": "listhen -w ./src/index.ts",
"build": "tsup",
"build:fix": "esno scripts/postbuild.ts",
"test": "vitest",
Expand All @@ -23,25 +24,34 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"bcrypt": "^5.1.1",
"colorthief": "^2.4.0",
"consola": "^3.2.3",
"dotenv": "^16.3.1",
"fast-xml-parser": "^4.2.7",
"h3": "^1.8.0",
"listhen": "^1.4.0",
"fast-xml-parser": "^4.3.2",
"h3": "^1.8.2",
"jsonwebtoken": "^9.0.2",
"listhen": "^1.5.5",
"node-cron": "^3.0.2",
"ofetch": "^1.3.3",
"sanitize-html": "^2.11.0",
"sqlite3": "^5.1.6",
"tsx": "^3.12.7",
"tsx": "^3.13.0",
"vue": "^3.3.4"
},
"devDependencies": {
"@antfu/eslint-config": "^0.41.0",
"@types/node": "^20.5.6",
"@vitest/coverage-v8": "^0.34.3",
"@antfu/eslint-config": "1.0.0-beta.18",
"@types/bcrypt": "^5.0.0",
"@types/jsonwebtoken": "^9.0.3",
"@types/node": "^20.8.2",
"@types/sanitize-html": "^2.9.1",
"@vitest/coverage-v8": "^0.34.6",
"chalk": "^5.3.0",
"eslint": "^8.47.0",
"eslint": "^8.50.0",
"esno": "^0.17.0",
"fast-glob": "^3.3.1",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"vitest": "^0.34.3"
"vitest": "^0.34.6"
}
}
Loading

0 comments on commit 59dbae5

Please sign in to comment.