GithubHelp home page GithubHelp logo

smartive / giuseppe Goto Github PK

View Code? Open in Web Editor NEW
48.0 48.0 7.0 4.12 MB

A controller routing system for expressJS with TypeScript decorators and annotations

Home Page: http://giuseppe.smartive.ch

TypeScript 73.93% HTML 9.57% CSS 16.50%
api decorators express expressjs giuseppe routing typescript

giuseppe's People

Contributors

buehler avatar dwirz avatar greenkeeper[bot] avatar mfeltscher avatar nickredmark avatar remojansen 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

giuseppe's Issues

Add setup guide

Add a guide or even yeoman "integration" to get an example app running quickly.

Logging support

add a possibility to add a custom logging framework (via an interface) to enable logging for giuseppe
(maybe graylog or such a thing)

TS2688: Cannot find type definition file for 'chai'.

Cannot find type definition file for 'chai'.

Error on compiling.

-> ParamDecorator.d.ts

/// <reference types="chai" />
import 'reflect-metadata';
import { BodyParamOptions, CookieParamOptions, ParamOptions, QueryParamOptions } from './ParamOptions';
/**
 * Reflect metadata key for parameter list.
 * @type {string}
 */
export declare const PARAMS_KEY: string;

Possibility to filter registration

Controller that are only registered to certain routers.

This would add the possibility to create multiple sections of a site like:

registerControllers('user', userRouter);
registerControllers('admin', adminRouter);

Plugin system

We may need a plugin system to enhance the way, giuseppe is handling everything.

This could support the following example

  • "giuseppe-handlebars" -> you could return data to a handlebars template and return a html view result

possibility to order the registrations

Since express has the possibility to add default routes (routes with * in it) we need to provide any way of ordering the registrations.

If we don't, the (random) order of the decorators would define the wildcard routes.

One usecase:

  • api controller with /api/....
  • static file controller for a single page application /* with a catch all that is not registered to send the index.html

Dependency Injection for controller instances

since controllers are instantiated, it would be cool to have some sort of a dependency injection (constructor injection?) to provide certain things via DI.

an example could be an instance of an elasticsearch client, or some other injected things

Body-Parser and Cookie-Parser packages

Should we add an error or a warning when @Body() is used and no body-parser package is installed?
A similar problem exists with the future of @Cookie param decorator. If there is no cookie-parser package, those two will always deliver undefined.

Maybe it's in the responsibility of the user since there could exist more than just body-parser or other default expressJS packages.

The routing does work unless you turn compiler option 'emitDecoratorMetadata' to 'true'

Hi,
I really like your idea and the controller registration using decorators. When trying to make it work on my side I spend about an hour of debugging to find out why the routing does not work and I'm getting 402 No Content.

In ControllerDecorator class on line 198 you're reading the return type of the route method. However, for this to work correctly the metadata must be emitted by the tsc compiler and that requires compiler option emitDecoratorMetadata to be set to true. This is not emphasized in the documentation. Can you please add this note to readme document?

Thanks,
Karel

Parameters: possibility for constructor functions

possibility to pass a constructor function for a parameter type
e.g.:

public foobar(@Query('bla', {constructor: Demo.create }) bla: Demo ){}

Or even a factory function:

public foobar(@Query('bla', {constructor: raw => Demo.create(raw) }) bla: Demo ){}

Add @Head route with boolean return value

/*...*/
@Head(':id')
public exists(@UrlParam('id') id: number): boolean {
    return true;
}
/*...*/

If head route is used and return value is Boolean use the correct and corresponding status codes to implement an "exists" route.

true -> res.status(httpStatus.SUCCESS);
false -> res.status(httpStatus.NOT_FOUND);

Use generic validators?

/*param options*/
validator<T>?: (value: T) => boolean

can still be any but can also be typed

Should we support websockets as well?

Should we enable giuseppe to support websocket (socket.io?) connections as well?

We could implement it like a SocketRoute (with the corresponding helpers SocketGet etc)

Definitely needs more investigating into the topic, but would be a cool feature.

Add warning when @Body is used without body-parser package

Add a console.warn that notifies the user when the @Body param decorator is used but no body-parser package is found. In the future maybe this warning should be configurable, since body parsing can be made on it's own.

Or maybe add own body parser to giuseppe.

Same procedure applies when @Cookie #23 is implemented

Route Versioning

It would be nice if we could introduce some kind of versioning for same routes e.g. @Get(':id', { version: '1.4.2' }) and @Get(':id', { version: '2.0.0' }) via header.

root routes

add possibility to ignore the previous route segments (i.e. from base url or controller base url)

possible on:

  • controller decorator
  • route decorator

with special character ~

Security decorators (middleware) ?

Hey, great library.

I was wondering if its possible to pass in custom middleware on a route or is it planned ?

or even better, protecting routes using security decorators ?

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.