Skip to content

Commit

Permalink
Merge 17381e2 into f7824a3
Browse files Browse the repository at this point in the history
  • Loading branch information
ndaidong committed Sep 17, 2022
2 parents f7824a3 + 17381e2 commit a6234fc
Show file tree
Hide file tree
Showing 18 changed files with 468 additions and 2 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ Here are default properties/values:
View [default options](https://github.com/ndaidong/article-parser/blob/main/src/config.js#L51)
Read [string-comparison](https://www.npmjs.com/package/string-comparison) docs for more info about `urlsCompareAlgorithm`.
#### Object `sanitizeHtmlOptions`:
Expand Down
171 changes: 171 additions & 0 deletions examples/bun-article-parser/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
\*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
\*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

\*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

\*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.cache
.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

.cache/

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp
.cache

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.\*

bun.lockb
20 changes: 20 additions & 0 deletions examples/bun-article-parser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# bun-article-parser

To install dependencies, please use `npm`, `pnpm`, `yarn` instead of `bun`

```bash
pnpm i
```

*`bun install` doesn't work as expected. Maybe a bug. It's new so let's give it time to fix.*


To run:

```bash
bun run index.ts
```

Open `http://localhost:3100/?url=https://www.freethink.com/technology/virtual-world` to see the result.

---
35 changes: 35 additions & 0 deletions examples/bun-article-parser/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Hono } from 'hono'

import { extract } from 'article-parser'

const app = new Hono()
app.get('/', async (c) => {
const url = c.req.query('url')
if (!url) {
return c.json({
service: 'article-parser',
lang: 'typescript',
server: 'hono',
platform: 'bun'
})
}
try {
const data = await extract(url)
return c.json({
error: 0,
message: 'article has been extracted successfully',
data
})
} catch (err) {
return c.json({
error: 1,
message: err.message,
data: null
})
}
})

export default {
port: 3100,
fetch: app.fetch,
}
11 changes: 11 additions & 0 deletions examples/bun-article-parser/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "bun-article-parser",
"module": "index.ts",
"devDependencies": {
"bun-types": "^0.1.0"
},
"dependencies": {
"article-parser": "^7.2.0",
"hono": "^2.1.4"
}
}
9 changes: 9 additions & 0 deletions examples/bun-article-parser/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "esnext",
"target": "esnext",
// "bun-types" is the important part
"types": ["bun-types"]
}
}
11 changes: 11 additions & 0 deletions examples/deno-article-parser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# deno-article-parser

With `deno`, we have not much thing to do. Just start the server:

```bash
deno run --allow-net --allow-env --allow-read index.ts
```

Open `http://localhost:3101/?url=https://www.freethink.com/technology/virtual-world` to see the result.

---
32 changes: 32 additions & 0 deletions examples/deno-article-parser/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { opine } from 'https://deno.land/x/opine@2.3.3/mod.ts'
import { extract } from 'https://esm.sh/article-parser@7.2.0-rc5'

const app = opine()

app.get('/', async (req, res) => {
const url = req.query.url
if (!url) {
return res.json({
service: 'article-parser',
lang: 'typescript',
server: 'opine',
platform: 'deno'
})
}
try {
const data = await extract(url)
return res.json({
error: 0,
message: 'article has been extracted successfully',
data
})
} catch (err) {
return res.json({
error: 1,
message: err.message,
data: null
})
}
})

app.listen({ port: 3101 })
17 changes: 17 additions & 0 deletions examples/node-article-parser/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Logs
logs
*.log
*.debug

# Runtime data
*.pid
*.seed

node_modules
coverage
.nyc_output

.DS_Store
yarn.lock
coverage.lcov
pnpm-lock.yaml
19 changes: 19 additions & 0 deletions examples/node-article-parser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# node-article-parser

Install dependencies:

```bash
pnpm i

# or yarn, npm
```

Start server:

```bash
npm start
```

Open `http://localhost:3102/?url=https://www.freethink.com/technology/virtual-world` to see the result.

---
32 changes: 32 additions & 0 deletions examples/node-article-parser/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import express from 'express'
import { extract } from 'article-parser'

const app = express()

app.get('/', async (req, res) => {
const url = req.query.url
if (!url) {
return res.json({
service: 'article-parser',
lang: 'javascript',
server: 'express',
platform: 'node'
})
}
try {
const data = await extract(url)
return res.json({
error: 0,
message: 'article has been extracted successfully',
data
})
} catch (err) {
return res.json({
error: 1,
message: err.message,
data: null
})
}
})

app.listen(3102)
13 changes: 13 additions & 0 deletions examples/node-article-parser/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "tsnode-article-parser",
"version": "1.0.0",
"main": "index.js",
"type": "module",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"article-parser": "7.2.0-rc5",
"express": "^4.18.1"
}
}

0 comments on commit a6234fc

Please sign in to comment.