Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cycle-director

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cycle-director - npm Package Compare versions

Comparing version 0.3.2 to 1.0.0

cycle-director.sublime-project

27

lib/index.js

@@ -72,2 +72,13 @@ 'use strict';

function addServerRoute(routes, route) {
routes[route.url] = {
before: route.before,
on: route.on,
get: route.get,
post: route.post,
put: route.put,
'delete': route['delete']
};
}
function wrapOptionsMethods(routerOptions, subject) {

@@ -91,3 +102,3 @@ if (routerOptions.notfound) {

function makeRouterDriver(routerOptions) {
function makeClientDriver(routerOptions) {

@@ -126,3 +137,13 @@ var router = new _director.Router();

exports['default'] = makeRouterDriver;
exports.makeRouterDriver = makeRouterDriver;
function makeHTTPDriver(routes) {
var routerOptions = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var router = new _director.http.Router(routes).configure(routerOptions);
return function () {
return router;
};
}
exports['default'] = makeClientDriver;
exports.makeClientDriver = makeClientDriver;
exports.makeHTTPDriver = makeHTTPDriver;

2

package.json
{
"name": "cycle-director",
"version": "0.3.2",
"version": "1.0.0",
"description": "A router driver for cycle.js based on director",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -11,3 +11,3 @@ # Cycle-Director

# Example
# Client Example

@@ -18,3 +18,3 @@ ```javascript

import makeRouterDriver from 'cycle-director';
import {makeClientDriver} from 'cycle-director';

@@ -24,6 +24,6 @@ let author = () => { return "author" };

let viewBook = (id) => {return "viewBook: bookId is populated: " + id};
let viewChapter = (bookId, chapterNumber) => { return "BookId: " + bookId + " Chapter: " + chapterNumber}
let viewChapter = (bookId, chapterNumber) => { return "BookId: " + bookId + " Chapter: " + chapterNumber}
let routes = [
{ url: "/author",
{ url: "/author",
on: author,

@@ -88,17 +88,47 @@ after: () => {if (!confirm("You sure you want to leave this page?")) {

### Route Object
- url (required): path to mount routing events
- optionally any [routing event](https://github.com/flatiron/director#routing-events) director supports
###### Example Route Object
```javascript
{
url: '/home', // required
before: () => console.log('Going home...'), // optional
once: () => console.log('Never been here before'), // optional
on: () => console.log('Welcome home...'), // optional
after: () => console.log('Leaving home...') // optional
}
```
- anything else: Its just a javascript object. Put whatever else you may need to complete your application. These are just the things that cycle-director will do something with.
# Server Side Example
### Uses [cycle-http-server](https://github.com/tylors/cycle-http-server)
```javascript
import {run} from '@cycle/core';
import {makeServerDriver} from 'cycle-http-server';
import {makeHTTPDriver} from 'cycle-director';
function helloWorld() {
this.res.writeHead(200, {'Content-Type': 'text/plain'});
this.res.end("Hello, world!");
}
let routes = {
"/hello": {
get: helloWorld
}
};
function main({Server, Router}) {
Server.subscribe( ({req, res}) => {
Router.dispatch(req, res, (err) => {
if (err) {
res.writeHead(404);
res.end(err.toString());
}
Router.get("/bonjour", helloWorld);
Router.get("/hola/", helloWorld);
Server.listen(3000);
}
let drivers = {
// Takes routes and [configuration](https://github.com/flatiron/director#configuration)
Router: makeHTTPDriver(routes, {
strict: false
}),
Server: makeServerDriver()
}
run(main,drivers);
```

@@ -0,3 +1,8 @@

<<<<<<< HEAD
import Rx from 'rx';
import {Router, http} from 'director';
=======
import {Rx} from '@cycle/core';
import {Router} from 'director';
>>>>>>> 2fd504b997eacc183ce7c40e03788407e48e5651

@@ -69,2 +74,13 @@

function addServerRoute(routes, route) {
routes[route.url] = {
before: route.before,
on: route.on,
get: route.get,
post: route.post,
put: route.put,
delete: route.delete
};
}
function wrapOptionsMethods(routerOptions, subject) {

@@ -88,3 +104,3 @@ if (routerOptions.notfound) {

function makeRouterDriver(routerOptions) {
function makeClientDriver(routerOptions) {

@@ -127,5 +143,12 @@ let router = new Router()

function makeHTTPDriver(routes, routerOptions={}) {
let router = new http.Router(routes).configure(routerOptions);
return () => router;
export default makeRouterDriver;
export {makeRouterDriver};
}
export default makeClientDriver;
export {makeClientDriver, makeHTTPDriver};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc