Git Product home page Git Product logo

seneca-examples's Introduction

seneca-examples - Node.js plugin examples for the Seneca toolkit

This repository is a collection of simple examples to get you started using senecajs.org.

Each example demonstrates the use of plugins to quickly create business logic for your qpp. View the app.js (or main.js) source code in each example for a fully commented walk through of the example.

Examples

  • data-entities: Using multiple databases at the same time for different kinds of entities.
  • simple-plugin: Create a simple Seneca plugin, including unit tests.
  • api-server: building a REST server with Seneca
  • plugin-web: creating plugins that expose web user interfaces
  • micro-services: create a small micro-services system
  • user-accounts: A user account system, showing login/logout logic.
  • shopping-cart: A shopping cart example, showing how plugins expose additional HTTP APIs.

seneca-examples's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

seneca-examples's Issues

micro-services is not working with Seneca versions later then 0.6.2

Message: seneca: Action init:user failed: seneca.make is not a function.

When I adding .use('entity') in user-details.js

equire('seneca')()
.use('user')
.use('entity')
.listen(10201)
.ready(function () {
this.act({role: 'user', cmd: 'register', nick: 'user', name: 'user', password: 'user'})
})
and in web-app.js,
seneca
.use('user')
.use('auth')
.use('entity')
.use('../lib/api.js')
no more errors but login is not working.
Is it right place I am adding it?

Broken Links

Nbd, but the micro-services link is broken, It doesn't have an absolute path.

Deprecate Module

Dear Maintainer(s),

To reduce the Seneca project's maintenance overhead, we have evaluated all the available plugins,
and have marked this one as a possible target for deprecation.

Our goal is to tidy up the Seneca ecosystem and ensure that our users are provided with well maintained and supported plugins.

We will not be killing or un-publishing any plugins, but instead we aim to move them all to a new 'senecajs-attic' organisation, where their current status will be more clearly signalled to potential users.

They can also be adopted by new maintainers if they are found to be useful to other developers.

If you as maintainer agree with this, and would like to stop maintaining this plugin, please

  1. change the owner of this github repo to the 'seneca-bot' user
  2. add the 'seneca-bot' user to npm owners with npm owner add seneca-bot

The seneca-bot user will then move the plugin to senecajs-attic and update the README with:

Project Status :

This plugin is not being supported by the Seneca organisation, and is no longer proven to work with the latest version of Seneca.
If you are interested in maintaining this project, please contact us via the issue queue.

If you feel that this plugin is still needed by yourself or your organisation, no action is needed on your part and you can close the issue.

We thank you for your time,

sincerely, the seneca project.

No cart found in engage plugin on app startup in shopping-cart example

After following the instructions in the README.txt for the shopping-cart example, navigating to http://localhost:3000 results in a large console error (see screenshot).

After investigation, I found the error in the handlecart function in /shopping-cart/app.js. When it is called in the app.get('/', ...) route configuration, the value "out" in the callback is undefined, meaning that no cart is found in the engage plugin.

For this reason, the call stack explodes with a 'Cannot read property "value" of undefined' error, but the server continues running, and the page simply says 'No data received'.

If I knew more about the engage plugin, I may be able to figure this one out on my own. But for now I don't know how to fix it. And with this error occurring, I have been unable to migrate the shopping cart example to express 4.

screenshot_071014_054305_pm

user-accounts not working anymore on latest versions

After updating npm dependecies to:

    "express": "~4.13.4",
    "body-parser": "~1.15.0",
    "cookie-parser": "~1.4.1",
    "method-override": "~2.3.5",
    "express-session": "~1.13.0",
    "serve-static": "~1.10.2",
    "optimist": "~0.6.1",
    "ejs": "~2.4.1",
    "ejs-locals": "~1.0.2",
    "seneca": "plugin",
    "seneca-user": "~1.0.0",
    "seneca-auth": "~0.4.0",
    "seneca-admin": "~0.2.0",
    "seneca-jsonrest-api": "~0.3.1",
    "seneca-perm": "~0.5.6",
    "seneca-data-editor": "~0.2.0"

The example just doesn't work anymore. Specifically, seneca-data-editor and seneca-admin plugins fail with:

cmd:load,role:entity,ent:{},name:user,base:sys,zone:null}   ENTRY   (ozx7g) -   seneca: Action cmd:load,role:entity callback threw: useract.register is not a function. act_callback    {message:useract.register is not a function,pattern:cmd:load,role:entity,instance:Seneca/1.1.0/wyy1pxnq0z7i/145 TypeError: useract.register is not a function

Many 404 errors on admin page in user-accounts example

Not sure if this is an error with the seneca-admin plugin or the implementation in the example. It is worth looking into either way.

After following the instructions in the README.txt, and logging in as user a1 as specified in the comments in app.js, I am getting 11 Not found errors for assets specified in the seneca-admin plugin. These errors include angular, underscore, jquery and bootstrap.

It may be that these modules need to be included as dependencies in the example, and script tags included somewhere there. It also may be that the admin plugin needs to be called in a different way than it currently is. My suspicion is that the admin plugin is not yet stable, and this bug may need to be moved to there.

screenshot_071014_061310_pm

api-server is not working with Seneca versions later then 0.6.2

Message: seneca: Ready function failed: this.make$ is not a function.
When I adding seneca.use('entity') I am getting errors running client.js

get /hello 200 {"msg":"hello!"}
get /product 500 {"error":"Error: seneca: No matching action pattern found for { base: '-', method: 'get', name: 'Seneca/2.1.0/lir29mu39dmf/1464779505386/3004/-', prefix: '/', role: 'jsonrest-api', zone: '-', kind: 'product', id: 'lir29mu39dmf/1464779505386/3004/-', q: {}, did: '(5sryxctocx07)', toString: [Function], fixedargs: { 'req$': IncomingMessage { _readableState: [Object], readable: true, domain: null, _events: {}, _eventsCount: 0, _maxListeners: undefined, socket: [Object], connection: [Object], httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', complete: true, headers: [Object], rawHeaders: [Object], trailers: {}, rawTrailers: [], upgrade: false, url: '/product', method: 'GET', statusCode: null, statusMessage: null, client: [Object], _consuming: false, _dumped: false, next: [Function: next], baseUrl: '', originalUrl: '/product', _parsedUrl: [Object], params: [Object], query: {}, res: [Object], body: {}, seneca: [Object], _route_index: 0 }, 'res$': ServerResponse { domain: null, _events: [Object], _eventsCount: 1, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: false, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: true, _removedHeader: {}, _contentLength: null, _hasBody: true, _trailer: '', finished: false, ........get /product/0/star 400 {"why":"Bad input."}
put /product/0/star 400 {"why":"Bad input."}
get /product/0/star 400 {"why":"Bad input."}

Error running shopping-cart example

Using seneca 0.5.20.

steps:

  • $ node app.js -p 3000
  • visit http://localhost:3000

Error is shown below:

ERROR   act engage  -   OUT i303sfktwfx6    role:engage,cmd:set Seneca/0.5.20/aimvnzu7913a/1409924365092/-: load-without-query: [ 'load-without-query', { entity: $-/sys/engage:{id=;} } ]  action-execute  {id=i303sfktwfx6,gate=false,ungate=true,pattern=role:engage,cmd:set,plugin={name=engage,tag=undefined},time={start=1409924375013}}  Error: Seneca/0.5.20/aimvnzu7913a/1409924365092/-: load-without-query: [ 'load-without-query', { entity: $-/sys/engage:{id=;} } ]
    at Seneca.fail (~/projects/seneca/lib/seneca.js:1670:15)
    at Entity.load$ (~/projects/seneca/lib/entity.js:191:14)
    at ensure_engage (~/projects/seneca-examples/shopping-cart/node_modules/seneca-engage/engage.js:39:16)
    at Seneca.cmd_set (~/projects/seneca-examples/shopping-cart/node_modules/seneca-engage/engage.js:99:5)
    at Object.$.executor.execute.fn (~/projects/seneca/lib/seneca.js:1334:24)
    at Object._onImmediate (~/projects/seneca/lib/executor.js:93:14)
    at processImmediate [as _immediateCallback] (timers.js:345:15)

user-accounts is not working with Seneca versions later then 0.6.2

u.register({nick: 'u1', name: 'nu1', email: '[email protected]', password: 'u1', active: true})
^

TypeError: u.register is not a function
at Object. (/Users/kristina/Desktop/seneca-examplesMy/user-accounts/app.js:79:3)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3

Not working.. it gives the following error

{"kind":"add","case":"ADD","id":"transport_client_12","pattern":"cmd:*,role:user","name":"transport_client","level":"debug","plugin_name":"client$","seneca":"f7a3um19u28h/1512021509872/167/3.4.3/-","when":1512021510185}
/wkr/seneca-examples-master/micro-services/node_modules/express/lib/application.js:177
throw new TypeError('app.use() requires middleware functions');
^

TypeError: app.use() requires middleware functions
at Function.use (/wkr/seneca-examples-master/micro-services/node_modules/express/lib/application.js:177:11)
at Object. (/wkr/seneca-examples-master/micro-services/services/web-app.js:17:5)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)
at Function.Module.runMain (module.js:682:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:613:3

Seneca Fatal Error

Message: seneca: Action init:user failed: seneca.make is not a function.

Seneca-cart in npm is out of date

Steps to reproduce

$ git clone [email protected]:rjrodger/seneca-examples.git
$ cd seneca-examples 
$ npm install 

gives the following error
Looks like the version of seneca-cart in npm is out of date :(

npm http GET https://registry.npmjs.org/seneca-cart
npm http GET https://registry.npmjs.org/seneca-engage
npm http GET https://registry.npmjs.org/seneca
npm http 304 https://registry.npmjs.org/seneca-cart
npm http 304 https://registry.npmjs.org/seneca-engage
npm http 304 https://registry.npmjs.org/seneca
npm ERR! Error: No compatible version found: seneca-cart@'>=0.1.1-0 <0.2.0-0'
npm ERR! Valid install targets:
npm ERR! ["0.1.0"]
npm ERR!     at installTargetsError (/home/anton/github/lib/node_modules/npm/lib/cache.js:722:10)
npm ERR!     at next (/home/anton/github/lib/node_modules/npm/lib/cache.js:701:17)
npm ERR!     at /home/anton/github/lib/node_modules/npm/lib/cache.js:678:5
npm ERR!     at saved (/home/anton/github/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:138:7)
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System SunOS 5.11
npm ERR! command "node" "/home/anton/github/bin/npm" "install"
npm ERR! cwd /home/anton/github/seneca-examples
npm ERR! node -v v0.10.12
npm ERR! npm -v 1.3.1
npm http GET https://registry.npmjs.org/seneca/-/seneca-0.5.9.tgz
npm http 200 https://registry.npmjs.org/seneca/-/seneca-0.5.9.tgz
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/anton/github/seneca-examples/npm-debug.log
npm ERR! not ok code 0

data-entities not working

Tried with different versions of Seneca, no luck:

Seneca Fatal Error

Message: seneca: Action init:jsonfile-store,tag:foo failed: seneca-jsonfile-store: folder-not-found.

Code: act_execute

Details: { folder: 'foo-data',
store: 'jsonfile-storefoo-/foo/-',
message: 'seneca-jsonfile-store: folder-not-found',
pattern: 'init:jsonfile-store,tag:foo',
fn: [Function],
cb: [Function],
instance: 'Seneca/0.6.2/1ztyglk8zyxj/1464364988309/8850/-',
'orig$':
{ [Error: seneca-jsonfile-store: folder-not-found]
eraro: true,
orig: null,
code: 'folder-not-found',
'seneca-jsonfile-store': true,
package: 'seneca-jsonfile-store',
msg: 'seneca-jsonfile-store: folder-not-found',
details: { folder: 'foo-data', store: 'jsonfile-storefoo-/foo/-' },
callpoint: 'at /Users/kristina/Desktop/seneca-examplesMy/data-entities/node_modules/seneca-jsonfile-store/jsonfile-store.js:300:21' },
'message$': 'seneca-jsonfile-store: folder-not-found',
plugin: {} }

cannot find module "engage"

the module "engage" is missing from the shopping cart example,

this issue would have been a pull request, but "engage" wasn't in the npm registry either :(

~/c/seneca-examples/shopping-cart>node app.js 
2013-02-28T00:30:56.089Z    INFO    init    start
2013-02-28T00:30:56.095Z    INFO    init    end

/Users/dominictarr/c/seneca-examples/shopping-cart/node_modules/seneca/lib/seneca.js:195
        if( first_err ) throw first_err;
                              ^
Error: Cannot find module 'engage'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at try_require (/Users/dominictarr/c/seneca-examples/shopping-cart/node_modules/seneca/lib/seneca.js:138:19)
    at resolve_plugin (/Users/dominictarr/c/seneca-examples/shopping-cart/node_modules/seneca/lib/seneca.js:194:41)
    at EventEmitter.self.use (/Users/dominictarr/c/seneca-examples/shopping-cart/node_modules/seneca/lib/seneca.js:1048:5)
    at Object.<anonymous> (/Users/dominictarr/c/seneca-examples/shopping-cart/app.js:23:8)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)

shopping-cart is not working with Seneca versions above 0.6.2

This error is coming up after clicking on product:

Seneca Fatal Error

Message: seneca: Action cmd:save,role:entity failed: Cannot read property 'encrypted' of undefined.

Code: act_execute

Details: { id: 'hbmiw3zgr0n4/lmx841iaeidh',
gate: false,
ungate: true,
desc: undefined,
cb: [Function],
fn: [Function],
time: { start: 1464774481106 },
'orig$': [TypeError: Cannot read property 'encrypted' of undefined],
'message$': 'Cannot read property 'encrypted' of undefined',
message: 'Cannot read property 'encrypted' of undefined',
pattern: 'cmd:save,role:entity',
instance: 'Seneca/1.4.0/crxztf423s4o/1464774470801/1296/-',
plugin: {} }

Stack:
at IncomingMessage.protocol (/Users/kristina/Desktop/seneca-examples/shopping-cart/node_modules/express/lib/request.js:288:30)
at /Users/kristina/Desktop/seneca-examples/shopping-cart/node_modules/seneca-mem-store/node_modules/lodash/index.js:3073:32
at baseForOwn (/Users/kristina/Desktop/seneca-examples/shopping-cart/node_modules/seneca-mem-store/node_modules/lodash/index.js:2046:14)
at baseClone (/Users/kristina/Desktop/seneca-examples/shopping-cart/node_modules/seneca-mem-store/node_modules/lodash/index.js:1733:39)
at /Users/kristina/Desktop/seneca-examples/shopping-cart/node_modules/seneca-mem-store/node_modules/lodash/index.js:1734:23
at /Users/kristina/Desktop/seneca-examples/shopping-cart/node_modules/seneca-mem-store/node_modules/lodash/index.js:3073:15
at baseForOwn (/Users/kristina/Desktop/seneca-examples/shopping-cart/node_modules/seneca-mem-store/node_modules/lodash/index.js:2046:14)
at baseClone (/Users/kristina/Desktop/seneca-examples/shopping-cart/node_modules/seneca-mem-store/node_modules/lodash/index.js:1733:39)
at /Users/kristina/Desktop/seneca-examples/shopping-cart/node_modules/seneca-mem-store/node_modules/lodash/index.js:1734:23
at arrayEach (/Users/kristina/Desktop/seneca-examples/shopping-cart/node_modules/seneca-mem-store/node_modules/lodash/index.js:1289:13)

Instance: Seneca/1.4.0/crxztf423s4o/1464774470801/1296/-
ALL ERRORS FATAL: action called with argument fatal$:true (probably a plugin init error, or using a plugin seneca instance, see senecajs.org/fatal.html)
at act_done (/Users/kristina/Desktop/seneca-examples/shopping-cart/node_modules/seneca/seneca.js:1222:29)

api-server example does not work

I've followed the instructions:

npm i
node app.js...

and in another terminal:
node client.js

Neither the client nor the server displays any console output concerning the request. It just holds. Tested on a macbook with node 0.12 and 4.2

I would try to solve that but I'm quite new to seneca :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.