
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
firebase-hackernews
Advanced tools
Hacker News APIs with firebase
$ npm install --save firebase-hackernews
Run node script at ./example/express/server.js
, or npm run express and connect to server
This project was generated by create-react-app
. Navigate to ./example/react/
and then run first npm install
, an then run npm start
. If you have any updates before run start
, you should reinstall the package
To test service worker, run npm run sw
and connet to test server. webpack watching is default options
See more examples in test.js and refer to HackerNews API for more information of firebase and
Because of firebase running environment is not only for node but also browser and service worker.So you must import both of app and database from firebase
modules before import firebase-hackernews
.
const firebase = require('firebase');
const hackernews = require('firebase-hackernews');
// create a service as a single instance when the fist call
// you must pass firebase to init method
const hnservice = hackernews(firebase)
Even it can be running with es2015 to support for live-code importing like this below,
import firebase from 'firebase/app'
import from 'firebase/database'
const hnservice = hackernews(firebase)
// get all of stories by types, 'top', 'new', 'best', 'ask', 'show', 'job'
hnservice.stories('top').then(stories => {})
// get stories with custom count and page
hnservice.stories('top', {page: 1, count: 30}).then(stories => {})
// get a user
hnservice.user('jl').then(user => {})
// get a current max item id
hnservice.maxItem().then(update => {})
// get a updated items and profiles
hnservice.update().then(update => {})
APIs named to xxxxCached is that support return data immediately but synchronous APIs doesn't do fetch. It only works on cached data that means asynchronous apis alreay has been called or running on watch mode
hnservice.storiesCached('top').then(stories => {})
This module supports that running on server-worker. After initialzing in service worker, you can get a data via fetch. To do this, firstly, you must import and initialize both of firebase and hackernews service
/* global importScripts hackernews */
importScripts('https://www.gstatic.com/firebasejs/4.1.2/firebase-app.js')
importScripts('https://www.gstatic.com/firebasejs/4.1.2/firebase-database.js')
importScripts('https://unpkg.com/firebase-hackernews@2.1.0')
hackernews.init(firebase, { watch: true })
and then you can request a stories via fetch and subpath. see more examples in examples/serice-worker
const stories = await fetch('./hackernews/top')
const storiesRes = await stories.json()
storiesRes.data.forEach(s => {
// manage a story
})
Returns hackernews service powered by firebase as a single instance
{
firebase: `firebase package. refer to usage above`
options: {
watch: `true / false, enable watch mode or not`
log: `log function, ex) console.log`
}
}
Returns stories with totalLength
as an additional info after fetched and cached with options:
Returns items by id[s] after fetched and cached with options:
Returns profile by id
Returns recent updates regardless fetched data
Returnes max item id of latest snapshot on firebase
Make the service keep listening on the changes of stories. It recommend to use it for desktop application and server side. refer to the example with express.js
Returns a length of cached items of the target type
Return cached all of items related to the target id. key is item's id and data will be flatted object list
Set and get data, on cache directly. It's useful when it comes to hydrate / serialis cache
Cached APIs returns with data immediately from chached data without fetch and Promise. It would be possible that data is not ready befor you do calll cached
APIs
MIT © Jimmy Moon
FAQs
Hacker News APIs with firebase
The npm package firebase-hackernews receives a total of 20 weekly downloads. As such, firebase-hackernews popularity was classified as not popular.
We found that firebase-hackernews demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.