jsonApi.listen = (port, callback) => { jsonApi.setConfig({ base: "rest", port: 4000, }); jsonApi.start(); if (callback) { process.nextTick(callback); } jsonApi.define({ resource: "articles", handlers: new jsonApi.MemoryHandler(), attributes: { title: jsonApi.Joi.string().required(), url: jsonApi.Joi.string().uri(), body: jsonApi.Joi.string().required(), publishedAt: jsonApi.Joi.date().iso() }, examples: [{ id: '11', // should be a string for memory handler type: 'articles', // should be same as "resource" title: 'Hello World', body: 'Exciting' }, { id: '12', // should be a string for memory handler type: 'articles', // should be same as "resource" title: 'Fresh News', body: 'Intresting' }] }); }
var jsonApi = require("jsonapi-server"); var posconfigHandler = require("../handlers/posconfigHandler.js"); jsonApi.define({ namespace: "json:api", resource: "posconfigs", description: "Represents discoverable configuration information for c-base-pos systems", handlers: posconfigHandler, attributes: { description: jsonApi.Joi.string().required() .description("A description of the configuration") .example("Example configuration"), created: jsonApi.Joi.string().isoDate() .description("The date and time on which the config was created, ISO 8601") .example("2016-04-17"), changed: jsonApi.Joi.string().isoDate() .description("The date and time on which the config was changed, ISO 8601") .example("2016-04-19T0341+00:00"), editor: jsonApi.Joi.one("people") .description("The last person editing it"), pricelists: jsonApi.Joi.many("pricelists") .description("All of the pricelists associated with this configuration"), account: jsonApi.Joi.one("accounts") .description("Account where money is registered") }, examples: [ { id: "default", type: "posconfigs", description: "Test configuration", created: "2016-04-17",
var jsonApi = require("jsonapi-server"); var posconfigHandler = require("../handlers/pricelistHandler.js"); jsonApi.define({ namespace: "json:api", resource: "pricelists", description: "Represents good-to-price mappings for c-base-pos systems", handlers: posconfigHandler, attributes: { description: jsonApi.Joi.string().required() .description("A description of the price list") .example("Example pricelist"), color: jsonApi.Joi.string().hex().length(6) .description("Color to identify buttons or items related to this pricelist"), label: jsonApi.Joi.string().hex().length(6) .description("Label for buttons related to this pricelist"), created: jsonApi.Joi.string().isoDate() .description("The date and time on which the price list was created, ISO 8601") .example("2016-04-17"), changed: jsonApi.Joi.string().isoDate() .description("The date and time on which the price list was changed, ISO 8601") .example("2016-04-19T0341+00:00"), editor: jsonApi.Joi.one("people") .description("The last person editing it"), validfrom: jsonApi.Joi.string().isoDate() .description("The date and time after which the price list is valid") .example("2016-04-17"), validto: jsonApi.Joi.string().isoDate() .description("The date and time until which the price list is valid") .example("2116-04-17"), configs: jsonApi.Joi.belongsToMany({