-
Notifications
You must be signed in to change notification settings - Fork 131
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
18 changed files
with
468 additions
and
2 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
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,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 |
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,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. | ||
|
||
--- |
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,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, | ||
} |
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,11 @@ | ||
{ | ||
"name": "bun-article-parser", | ||
"module": "index.ts", | ||
"devDependencies": { | ||
"bun-types": "^0.1.0" | ||
}, | ||
"dependencies": { | ||
"article-parser": "^7.2.0", | ||
"hono": "^2.1.4" | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["ESNext"], | ||
"module": "esnext", | ||
"target": "esnext", | ||
// "bun-types" is the important part | ||
"types": ["bun-types"] | ||
} | ||
} |
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,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. | ||
|
||
--- |
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,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 }) |
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,17 @@ | ||
# Logs | ||
logs | ||
*.log | ||
*.debug | ||
|
||
# Runtime data | ||
*.pid | ||
*.seed | ||
|
||
node_modules | ||
coverage | ||
.nyc_output | ||
|
||
.DS_Store | ||
yarn.lock | ||
coverage.lcov | ||
pnpm-lock.yaml |
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,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. | ||
|
||
--- |
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,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) |
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": "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" | ||
} | ||
} |
Oops, something went wrong.