https://github.com/permafrost-dev/hacker-news-graphql
Hacker News GraphQL server
https://github.com/permafrost-dev/hacker-news-graphql
graphql graphql-server hackernews
Last synced: about 2 months ago
JSON representation
Hacker News GraphQL server
- Host: GitHub
- URL: https://github.com/permafrost-dev/hacker-news-graphql
- Owner: permafrost-dev
- Created: 2021-06-03T12:06:01.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2026-02-13T19:16:54.000Z (5 months ago)
- Last Synced: 2026-02-14T02:29:52.272Z (5 months ago)
- Topics: graphql, graphql-server, hackernews
- Language: TypeScript
- Homepage:
- Size: 97.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hacker News GraphQL server
## Development setup
Create a `.env` file in the project directory:
```
NODE_ENV=development
PORT=3000
HACKERNEWS_API_URL=https://hacker-news.firebaseio.com/v0
CACHE_DRIVER=memory
```
_The `CACHE_DRIVER` variable can be either `memory` or `redis` - if `redis`, then a Redis service is assumed to be running._
Then install the dependencies and run `start:dev`, which both builds the application using `esbuild` and runs it:
```bash
npm install
npm run start:dev
```
Browse to `http://127.0.0.1:3000/graphql` in your browser to open the GraphiQL explorer.
## Examples
Return the first 5 top stories from HN:
```gql
query {
stories(first: 5, kind: TOP) {
title
url
time
commentCount
score
author {
id
karma
}
comments(first: 2) {
author {
id
karma
}
time
text
}
}
}
```
## Running tests
To run the tests successfully, you need to start the test http server first, which returns the data stored in `tests/fixtures`.
Once the test http server is running, you may run the jest test suite using `npm run test`.
```bash
cd tests/server
npm install
cd -
node tests/server/index.js &
npm run test
```