<commit_before>'use strict'

const path = require('path')
const express = require('express')
const hackernews = require('../../')

const app = express()
const news = hackernews()
const watchmode = process.argv.includes('--watch')
const index = `
<ul>
	<li><a href="/stories/top">top</a></li>
	<li><a href="/stories/new">new</a></li>
	<li><a href="/stories/best">best</a></li>
	<li><a href="/stories/ask">ask</a></li>
	<li><a href="/stories/show">show</a></li>
	<li><a href="/stories/job">job</a></li>
	<li><a href="/users/jl">users/jl</a></li>
	<li><a href="/maxitem">maxitem</a></li>
	<li><a href="/updates">updates</a></li>
</ui>`

app.get('/', (req, res) => {
	res.send(index)
})

app.get('/stories/:type', (req, res) => {
	news.stories(req.params.type).then(data => res.send(data))
})

app.get('/users/:id', (req, res) => {
	news.user(req.params.id).then(data => res.send(data))
})

app.get('/maxitem', (req, res) => {
	news.maxItem().then(data => res.send(`maxitem: ${data}`))
})

app.get('/updates', (req, res) => {
	news.update().then(data => res.send(data))
})

app.use('/hackernews', express.static(path.join(path.resolve(__dirname, '../'))))

Promise.resolve(watchmode && news.watch()).then(() => {
	app.listen(3000, () => {
		console.log(`server has started with ${watchmode ? 'watch' : 'fetch'} mode`)
	})
})
<commit_msg>Add paging mode route<commit_after>'use strict'

const path = require('path')
const express = require('express')
const hackernews = require('../../')

const app = express()
const news = hackernews()
const watchmode = process.argv.includes('--watch')
const index = `
<ul>
	<li><a href="/stories/top">top</a></li>
	<li><a href="/stories/top?page=1&count=1">top at page 1</a></li>
	<li><a href="/stories/new">new</a></li>
	<li><a href="/stories/best">best</a></li>
	<li><a href="/stories/ask">ask</a></li>
	<li><a href="/stories/show">show</a></li>
	<li><a href="/stories/job">job</a></li>
	<li><a href="/users/jl">users/jl</a></li>
	<li><a href="/maxitem">maxitem</a></li>
	<li><a href="/updates">updates</a></li>
</ui>`

app.get('/', (req, res) => {
	res.send(index)
})

app.get('/stories/:type', (req, res) => {
	console.log(req.query);
	news.stories(req.params.type, {
		page: req.query.page,
		count: req.query.count
	}).then(data => res.send(data))
})

app.get('/users/:id', (req, res) => {
	news.user(req.params.id).then(data => res.send(data))
})

app.get('/maxitem', (req, res) => {
	news.maxItem().then(data => res.send(`maxitem: ${data}`))
})

app.get('/updates', (req, res) => {
	news.update().then(data => res.send(data))
})

app.use('/hackernews', express.static(path.join(path.resolve(__dirname, '../'))))

Promise.resolve(watchmode && news.watch()).then(() => {
	app.listen(3000, () => {
		console.log(`server has started with ${watchmode ? 'watch' : 'fetch'} mode`)
	})
})

{'fraction_non_alphanumeric': 0.2794326241134752, 'fraction_numerical': 0.003900709219858156, 'mean_word_length': 4.653306613226453, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 105, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5972871', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1101, 'n_words': 174}