Skip to content

Appstax/appstax-express

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Appstax middleware for express.js

  • Forwards the "x-appstax-sessionid" header to calls using the appstax-js sdk.
  • Sets the neccesary CORS headers for using the appstax sdk on the client side.

Installing

> npm install appstax-express --save

Example usage

You initialize appstax with your app key as usual, and add use appstax.sessions() and appstax.cors() to apply the neccesary middleware.

var express = require("express");
var appstax = require("appstax-express");

var app = express();

appstax.init("your-app-key");
app.use(appstax.sessions());
app.use(appstax.cors("mydomain.appstax.io"));

app.get("/api/mydata", function(req, res) {

  // calls to appstax sdk methods will have the correct session id
  appstax.findAll("messages").then(function(messages) {
    // returns objects where the requesting session has read access
  })

});

About

Appstax middleware for express.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published