Git Product home page Git Product logo

cottage's Introduction

๐Ÿ‘‹ I'm Jun- currently building Ace, AI project manager that gives teams perfect memory by auto-collecting & documenting recent work history.

My life story TL;DR

cottage's People

Contributors

nebu1eto avatar therne avatar

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

cottage's Issues

Rest/Spread functionality not natively supported in 7.*

Just noticed when attempting to run Cottage with Node 7.7.x that there was an immediate stack trace with the following. It appears as though you've written Cottage for Node 8 while saying it supports earlier:

C:\node_modules\cottage\lib\router.js:29
            ...options
            ^^^
SyntaxError: Unexpected token ...
    at createScript (vm.js:53:10)
    at Object.runInThisContext (vm.js:95:10)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\node_modules\cottage\lib\application.js:3:16)

cmd>node -v
v7.7.3

Social Auth for Mobile

Congrats for building the fastest koajs framework!
What would be the best way to implement say 'Login with Google'?

Wildcard handlers not called if start of the path matches with a static path route

Current behavior

Registering a middleware with a given path (for example /a) and a wildcard path (*) on the same Router instance will cause the wildcard middleware handler to not be called if the path we navigate to starts with the given path (for example /b will work, but /ab will return a 404 page).

Using a param handler instead of a wildcard middleware (.get('/:param', () => {...})) results in the same behavior.

Expected behavior

The wildcard middleware handler should be called if the path doesn't match.

Reproduction

const {Cottage} = require('cottage');
const Koa = require('koa');

const app = new Koa();
const router = new Cottage();

router.use('/a', (ctx) => {
	console.log(Date.now(), 'a', ctx.url);
	ctx.body = 'a';
});

// Path is implicitly '*'
// Replacing this with `router.get('/:param', ...)` also results in an error
router.use((ctx) => {
	console.log(Date.now(), 'wildcard', ctx.url);
	ctx.body = 'wildcard';
});

app.use(router.callback());

app.listen(8080);
  • Navigating to /a returns a
  • Navigating to /ab returns Not Found
  • Navigating to /b returns wildcard

Environment

Cottage: v3.1.3 (npm latest)

Use HTTPS

You can enforce HTTPS connecting.
If you want to do, read this post and set configuration.
It might need some change for gh-pages branch to change URLs in html.

Update examples to Cottage v3

Attempting to figure out how to capture params from the URL with v3. There's currently sparse documentation on this at the moment and the examples in the repo are for a previous version.

I'm currently experimenting with how I can access the params, but in the absence of me figuring that out can you please update the documentation or comment on this issue?

Types are missing the `ctx.request.params` property

Current behavior

Using the following code in TypeScript results in an error:

import {Cottage} from 'cottage';
const router = new Cottage();
router.get('/:id', (ctx) => {
    return `Requested id: ${ctx.request.params.id}`; // Property 'params' does not exist on type 'Request'. ts(2339)
});

Expected behavior

The types correctly recognize the Request.params property.

Environment

Cottage v3.1.3 (npm latest)
TypeScript v3.9.6

paramNode attached at root is not working.

Steps to reproduce:

const router = new Cottage();
router.get('/:id', async () => 'Hello');
router.put('/:id', async () => 'Hello'); // ERROR!

Error Log :

Error: something had been wrong
    at Tree.add (/Users/vista/cottageTest/node_modules/cottage/lib/tree.js:82:11)
    at Tree.addHandler (/Users/vista/cottageTest/node_modules/cottage/lib/tree.js:92:24)
    at Application.register (/Users/vista/cottageTest/node_modules/cottage/lib/router.js:146:19)
    at handlers.forEach (/Users/vista/cottageTest/node_modules/cottage/lib/router.js:106:22)
    at Array.forEach (<anonymous>)
    at Application.registerMultiple (/Users/vista/cottageTest/node_modules/cottage/lib/router.js:103:18)
    at Application.Router.(anonymous function) [as put] (/Users/vista/cottageTest/node_modules/cottage/lib/router.js:213:14)
    at run (/Users/vista/cottageTetst/index.js:4:7)

Seems like node traversal calculation is wrong with paramNode attached to root.

Not spectified dependencies in package.json.

Thanks for awesome project. ๐Ÿ‘
I think should have to declare dependencies in npm releases.

% node index.js                                                         
module.js:442
    throw err;

Error: Cannot find module 'methods'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (../project/node_modules/cottage/lib/route.js:2:15)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)`

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.