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

feathers-filemaker-bmangus

v1.0.1

Published

Filemaker adapter for feathers.js

Downloads

3

Readme

fms

Build Status

A FileMaker Adapter For Feathers.js.

About

This is a FileMaker Adapter for feathers.js. It makes it trivial to create a feathers service for any FileMaker Layout. For non FileMaker people, a layout is a Table with a defined set of fields, and related records.

This currently passes all but two tests in the feathers-service-test suite. There is not an easy way to do a a true PUT, which would require nulling fields. When you PUT or in feathers terms 'update', you basically just get a PATCH. We also do not support the $in and $nin query filters. We may in the future. Support for $or is limited. Only single fields will work.

Install

npm install feathers-filemaker-bmangus --save

Documentation

This adapter works like others Feathers Adapters. Please refer to the Feathers database adapter documentation for more details or directly at:

FileMaker Specific Configuration

This adapter takes two additional keys in it's configuration object: connection and model

Connection

  connection :{
    host : 'localhost',  // server address
    db : 'Contacts'
    user : 'admin'
    pass : 'pass'
  }

Model

model :{
  layout : 'Contacts' // the layout for the service
  idField : 'id'  // primary key field name, defaults to 'id'

Connection specifies the host, database, user, and password to connect to the database. model specifies the layout and idField to use for the feathers service. See the complete example below for more information.

Script Service

There is also an included ScriptService that will run scripts on a specified layout. That layout must be based on a dedicated TO and Table. The service creates a record in that table and dumps the data in a field before running the script. See the "Utility" Table and layout in the Test file. Add that table to your solution. The records it creates are great for logging purposes. But can be destroyed at will.

The Service will return JSON as it normally does from the last layout it is on. However if you end the script on 'Utility' layout, then it is smart enough to pull the result from the 'results' field. This lets you create custom responses with worrying about having a table to produce them from. However the "result" will be parsed as JSON so you need to make sure it is valid JSON.

This is great for running transactions scripts!

PLEASE NOTE: This portion of the repository differs from the master branch. Please read the following documentation carefully.

Using the Script Service

//import the module and service
const feathers = require('@feathersjs/feathers');
const express = require('@feathersjs/express');
var fms = require('feathers-filemaker');
var script = fms.ScriptService;

// Creates an Express compatible Feathers application (for endpoint example below)
const app = express(feathers());

app.configure(express.rest());

//Begin Script Service
//---configure the script service
app.configure(script({connection, layout: 'fm_web_layout', idField: 'recordID'}));

//---get the service
const ScriptService = app.service('fms-someFile-someLayout-script');

//---setup endpoint to run the service (using standard express routing)
app.use('/run/:urlParam',
   (req, res, next) => { 
     return ScriptService.run('someScript', {param: req.params.urlParam})
      .then((data) => { 
        res.send(parseJSON(data)) })
      .catch("error"); }
);

//End Script Service

Complete Example

const feathers = require('@feathersjs/feathers');
const express = require('@feathersjs/express');
var fms = require('feathers-filemaker-bmangus');
const memory = require('feathers-memory');
var script = fms.ScriptService;

// Creates an Express compatible Feathers application
const app = express(feathers());

app.configure(express.rest());

//DB connection
const connection = {
  host : 'fms.somewhere.com',
  db : 'someFile',
  user : 'someUser',
  pass : 'somePassword',
};

//Parse json string into usable response

var parseJSON = (data) => {
  return JSON.parse(data.result);
}


//example endpoint 1
app.use('/classifications', fms({
  connection,
  model :{
    layout : 'classifications_web',
    idField : 'recordID',
  },
  paginate: {
    default: 2,
    max: 4,
  }
}));

//example endpoint 2
app.use('/class_list', fms({
    connection,
    model:{
        layout: 'class_list_web',
        idField: 'recordID',
    }
}));



// Start the server.
var port = 3030;

app.listen(port, function() {
  console.log(`Feathers server listening on port ${port}`);
});

Auto Service

EXPERIMENTAL - Use with caution.

In addition to setting up services using normal feathers idioms as described above, you can simply expose a RESTFUL endpoint to all the databases on the server. This is super simple to setup. It covers many of the common scenarios that REST is used for, however it is less powerful than normal feathers services.

The Auto Service serves a restful endpoint in the following form:

  • http://<address>:<port>/<prefix>/db/layout
  • http://<address>:<port>/<prefix>/db/layout/id

The prefix can be passed in as part of configuration. ( see below )

This will also work with WebSockets, but it's weird. And is currently doesn't have authentication. TODO:examples

Authentication

Basic auth is the only option available to the Simple REST Service. JSONWeb Tokens currently won't work.

Limitations

You can't use feathers hooks.

How it works

You start by creating a normal feathers server. Then setup the Simple REST Server using configure()

Note: it takes the same options as a normal Feathers-FileMaker Service, plus one more "prefix" which is where the REST API is mounted ( See above )

Connection and model are the same with a regular Service, but some of the properties aren't used or are used only as defaults

  • Connection.db is ignored
  • Connection.user is a default, and is overridden by basic auth
  • Connection.password is a default, and is overridden by basic auth
  • Model.layout is ignored.

Example:

// app.js of generated feathers app
const path = require('path');
const serveStatic = require('feathers').static;
const favicon = require('serve-favicon');
const compress = require('compression');
const cors = require('cors');
const feathers = require('feathers');
const configuration = require('feathers-configuration');
const hooks = require('feathers-hooks');
const rest = require('feathers-rest');
const bodyParser = require('body-parser');
const socketio = require('feathers-socketio');
const middleware = require('./middleware');
const services = require('./services');

//get SimpleRestService from feathers-filemaker
const fm = require('feathers-filemaker');
const SimpleRestService = fm.SimpleRESTService;

// you'll need a connection
const connection = {
  host : 'localhost',
  db : 'Test',  // ignored
  user : 'wrong',   // optional, overwritten by basic auth
  pass : 'wrong'    // optional, overwritten by basic auth
};

const app = feathers();

app.configure(configuration(path.join(__dirname, '..')));

app.use(compress())
  .options('*', cors())
  .use(cors())
  .use(favicon( path.join(app.get('public'), 'favicon.ico') ))
  .use('/', serveStatic( app.get('public') ))
  .use(bodyParser.json())
  .use(bodyParser.urlencoded({ extended: true }))
  .configure(hooks())
  .configure(rest())
  .configure(socketio())
  .configure(services)
  
  //configure SimpleRestService here
  .configure(SimpleRestService({
    connection,
    prefix : 'rest'

  }))
  
  // middleware should be last
  .configure(middleware);


module.exports = app;

License

Copyright Todd Geist(c) 2016

Modified Brian Mangus 2018

Licensed under the MIT license