npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nextql-feathers

v0.0.2

Published

nextql plugin for feathers

Downloads

4

Readme

nextql-feathers

NextQL plugin for feathers. I not sure it for production, but it demonstrate how easy to extend NextQL

NPM version Build Status Dependency Status

  • NextQL : Yet Another Data Query Language. Equivalent GraphQL but much more simple.
  • Featherjs : A REST and realtime API layer for modern applications.

Notice: Current nextql-feathers only work with nextql >= 5.0.0

Install

npm install --save nextql-feathers

Why ?

NextQL just a data query engine. It required a client-side component, a transport and a data access component to complete. Featherjs just happen provide all of features. So shall we marry?

In fact, NextQL match perfect with Feathers:

  • NextQL use JS object as model, Feathers use JS object as service.
  • NextQL's methods could map to Feathers methods.
  • Finally, NextQL will complete Feathers with robust data/relationship query language.

Sample

nextql + feathers = Awesome!

const NextQL = require("nextql");
const nextql = new NextQL();


const feathers = require("feathers");
const app = feathers();
const NeDB = require("nedb");
const service = require("feathers-nedb");

// Create a NeDB instance
const Model = new NeDB({
	filename: "./data/messages.db",
	autoload: true
});

// Use nextql-feathers plugin 
nextql.use(require("nextql-feathers"), {
	app
});

// Define NextQL model which also a feathers service
nextql.model("messages", {
	feathers: {
		path: "/messages",
		service: service({ Model })
	},
	fields: {
		_id: 1,
		text: 1,
		newText: 1
	},
	computed: {
		owner() {
			return {
				name: "Giap Nguyen Huu"
			};
		}
	}
});


// Now NextQL work seamlessly with Feathers
await app.service("messages").find({
		query: {
			$params: { $limit: 2 }, // featherjs find params
			_id: 1,
			text: 1,
			owner: {
				name: 1 // !!! NextQL resolve computed value for featherjs
			}
		}
	})

await app.service("messages").get(1, {
		query: {
			_id: 1,
			text: 1,
			owner: {
				name: 1
			}
		}
	});


await app.service("messages").patch(
		2,
		{
			newText: "Text 2"
		},
		{
			query: {}
		}
	);

Features

Please check out featherjs-chat example with NextQL.

  • NextQL could real-time over Featherjs socket.io
  • Featherjs methods called with NextQL query. So you can query user information directly from messages service. Orginial version require you query addtional user service.
client
		.service("messages")
		.find({
			query: {
				$params: {
					$sort: { createdAt: -1 },
					$limit: 25
				},
				total: 1,
				limit: 1,
				skip: 1,
				data: {
					text: 1,
					owner: {
						name: 1
					}
				}
			}
		})
		.then(page => {
			page.data.reverse().forEach(addMessage);
		});
  • When you call create message, you provide NextQL query which filter data from Featherjs event - it's work like GraphQL subscription or Relay Fat Query without coding.
client
		.service("messages")
		.create(
			{
				text: input.value
			},
			{
				query: {
					text: 1,
					owner: {
						name: 1
					}
				}
			}
		)
		.then(() => {
			input.value = "";
		});
  • Thus event listenning from all clients will receive above NextQL query data.
// Listen to created events and add the new message in real-time
client.service("messages").on("created", addMessage);

Testing

 PASS  test/index.test.js
  ✓ find messages (8ms)
  ✓ get message (5ms)
  ✓ create message (2ms)
  ✓ update message (5ms)
  ✓ patch message (2ms) 
  ✓ remove message (3ms)

Test Suites: 1 passed, 1 total
Tests:       6 passed, 6 total
Snapshots:   0 total
Time:        0.908s, estimated 2s
Ran all test suites.

File      |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
All files |    97.92 |    89.29 |      100 |    97.87 |                |
 index.js |    97.92 |    89.29 |      100 |    97.87 |            121 |