Skip to content

Commit 5644324

Browse files
committed
Cosmetic updates
1 parent c4f4753 commit 5644324

5 files changed

Lines changed: 55 additions & 3 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,10 @@ List all crawl jobs.
585585

586586
Health check endpoint.
587587

588+
### `GET /about`
589+
590+
Credits and repository info. Returns: `{ name, version, by, repository }` (e.g. by: John F. Gonzales, repository: https://github.com/RantsRoamer/OpenScrape).
591+
588592
## Development
589593

590594
### Prerequisites

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openscrape",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "Open-source web scraping library with headless browser support, pagination, and data extraction",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/about.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* About / credits for OpenScrape (CLI and API)
3+
*/
4+
5+
export const ABOUT = {
6+
by: 'John F. Gonzales',
7+
repository: 'https://github.com/RantsRoamer/OpenScrape',
8+
} as const;
9+
10+
export function getAboutInfo(version: string) {
11+
return {
12+
name: 'openscrape',
13+
version,
14+
by: ABOUT.by,
15+
repository: ABOUT.repository,
16+
};
17+
}

src/api.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22
* REST API server for OpenScrape
33
*/
44

5+
import { readFileSync } from 'fs';
56
import express, { Request, Response, NextFunction } from 'express';
67
import { createServer } from 'http';
8+
import * as path from 'path';
79
import { OpenScrape } from './scraper';
810
import { ScrapeOptions, CrawlJob } from './types';
911
import { randomUUID } from 'crypto';
1012
import { attachWebSocketServer, broadcastJobEvent, closeWebSocketServer } from './websocket';
13+
import { getAboutInfo } from './about';
14+
15+
const pkg = JSON.parse(
16+
readFileSync(path.join(__dirname, '..', 'package.json'), 'utf-8')
17+
) as { version: string };
1118

1219
const app = express();
1320
app.use(express.json());
@@ -99,6 +106,13 @@ app.get('/health', (req: Request, res: Response) => {
99106
res.json({ status: 'ok', timestamp: new Date().toISOString() });
100107
});
101108

109+
/**
110+
* GET /about - Credits and repository
111+
*/
112+
app.get('/about', (req: Request, res: Response) => {
113+
res.json(getAboutInfo(pkg.version ?? '1.0.0'));
114+
});
115+
102116
/**
103117
* Process crawl job
104118
*/

src/cli.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,26 @@
44
* Command-line interface for OpenScrape
55
*/
66

7+
import { readFileSync } from 'fs';
78
import { Command } from 'commander';
89
import * as fs from 'fs/promises';
910
import * as path from 'path';
1011
import { OpenScrape } from './scraper';
1112
import { ScrapeOptions } from './types';
1213
import { toHtml, toText, toCsv, toYaml } from './formatters';
14+
import { ABOUT, getAboutInfo } from './about';
15+
16+
const packageJson = JSON.parse(
17+
readFileSync(path.join(__dirname, '..', 'package.json'), 'utf-8')
18+
) as { version: string };
19+
const version = packageJson.version ?? '1.0.0';
1320

1421
const program = new Command();
1522

1623
program
1724
.name('openscrape')
18-
.description('Open-source web scraping library')
19-
.version('1.0.0');
25+
.description('Open-source web scraping library. By: ' + ABOUT.by + ' | ' + ABOUT.repository)
26+
.version(version);
2027

2128
program
2229
.command('crawl')
@@ -200,6 +207,16 @@ program
200207
}
201208
});
202209

210+
program
211+
.command('about')
212+
.description('Show credits and repository')
213+
.action(() => {
214+
const info = getAboutInfo(version);
215+
console.log(`${info.name} v${info.version}`);
216+
console.log(`By: ${info.by}`);
217+
console.log(info.repository);
218+
});
219+
203220
program
204221
.command('serve')
205222
.description('Start the REST API server')

0 commit comments

Comments
 (0)