Janus

Node.js Handler for All Library Searches

code{4}lib 2016, March 9

David Naughton - UMN Libraries Web Development

naughton@umn.edu

Slides

http://z.umn.edu/c4ljanus

Common Problem

Many Search Targets

What to do for UMN's Library Data and Student Success?

A Solution - One Search Form to Rule them All

aka Bento Box

  • One example: Quick Search from NCSU
  • Very nice, but what if it doesn't meet your needs?

An Alternative - One Handler to Rule All the Search Forms

Privacy and Security

Single code-base to maintain.

Automate deleting of search data! We use logrotate.

Simpler Search Form Targets

Replaced this...

http://primo.lib.umn.edu/primo_library/libweb/action/dlSearch.do?institution=TWINCITIES&vid=TWINCITIES&indx=1&dym=true&highlight=true&lang=eng&search_scope=mncat_discovery&query=any%2Ccontains%2Cdarwin

Challenges - Testing

First attempt, with PHP/Guzzle: JavaScrip problems.

Solution? node.js!

Some people, when confronted with a problem, think "I know, I'll use node.js."

Now they have ω1 problems.

Challenges - node.js

The rest of the talk.

Installing node.js

OS Package

  • Will your sys-admins allow/support it?
  • Even if they do, version could be very old.

Installer/Version Manager

  • ndenv
  • nvm
  • n (Requires already-existing node.js)

node.js - Not a robust HTTP server.

Need a reverse proxy. Most common recommendation is nginx.

Still need to keep node.js running: forever or Supervisor or ...

May seem daunting. And what about risk-averse orgs?

Our Solution: Apache + Passenger

Phusion Passenger: Node.js tutorial

Configuring Passenger for node.js

Undocumented, but this works:


      Alias /janus /path/to/janus/public
      <Directory /path/to/janus/public>
        PassengerNodejs /path/to/node
        PassengerAppRoot /path/to/janus
        PassengerBaseURI /janus
      </Directory>
          

Asynchrony

Rapid Evolution of Approaches

Coroutines

  • "...computer program components that generalize subroutines for nonpreemptive multitasking, by allowing multiple entry points for suspending and resuming execution at certain locations." — Wikipedia
  • Coroutines, like ES7's async/await, make asynchronous code look synchronous.
  • Fundamentally different from previous approaches, which all use continuation-passing style.

Coroutines in ES(5|6)

koa

  • "next generation web framework for node.js", based on generators/coroutines.
  • Designed by the team behind Express.
  • Coroutines all the way down in koa v2, which will be alpha "until async/await hits node.js", but seems stable.

Thank you!

Open-source Janus coming soon.