Coder Social home page Coder Social logo

ts-web-framework's Introduction

npm version Known Vulnerabilities dependencies Status devDependencies Status Build status Codeship Status for TypeScript-Web-Framework/ts-web-framework Build Status Test Coverage Maintainability Inline docs contributions welcome HitCount GitHub issues GitHub stars GitHub license

NPM Greenkeeper badge

TypeScript Web Framework

Ideal to create Web Services.

Requeriments

  • Nodejs 6+
  • TypeScript 2.2+

Install(Windows, Linux and OSX)

First, install TypeScript Web Framework CLI

npm install -g twf-cli

Features

Command Line Interface

  • Own command line interface

Security

  • CSRF Prevention
  • Expect-CT
  • Content Security Policy
  • DNS Prefetch Control
  • X-Frame-Options
  • Hiden Powerd By
  • HTTP Public Key Pinning
  • HTTP Strict Transport Security
  • X-Download-Options for IE8+
  • No Cache
  • No Sniff
  • Referrer-Policy
  • XSS Prevention
  • AES-256-CTR, AES-256-GCM, AES-256-CBC Encrypt/Decrypt implementation
  • Single Binary file compilation
  • Denial-Of-Service Prevention

Easy Custom Responses

  • httpOk - 200
  • httpCreated - 201
  • httpAccepted - 202
  • httpRedirect - 301 & 307
  • httpBadRequest - 400
  • httpUnauthorized - 401
  • httpForbidden - 403
  • httpNotFound - 404
  • httpMethodNotAllowed - 405

Cross-platform

  • Microsoft Windows(XP, Vista, 8, 10, ...)
  • Linux (Ubuntu, Centos, Fedora, RedHat, ...)
  • OSX

Getting Started

Install TWF-CLI(TypeScript Web Framework Command Line Interface)

npm install -g twf-cli

Create you first project

twf start my-project

Create you first controller

Using TWF-CLI

twf add controller hello-world hello/world

Check you own controller

@Api('/api')
export class HelloWorldController extends Controller {
    @Http("/hello/world") // you route is : GET /api/hello/world
    public index () {
        this.httpOk();
    }
}

Commands

Compile

twf build

Test

twf test

Run/Serve

twf serve

Verify

twf verify

Package Single Binany

twf package

Licence

MIT License

Copyright (c) 2018 Olaf Erlandsen C.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ts-web-framework's People

Contributors

greenkeeper[bot] avatar olaferlandsen avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

ts-web-framework's Issues

Migrate to Webpack

  • Compile TypeScript
  • Minimize output
  • Compress output
  • Copy assets
  • Remove gulp

New Feature: @Api() set ROOT route

From now on, you can define the initial route for an @Api( root ).

  • @Api
    • Define root Route
    • Enable Manifiest to using root path.
  • Create Unit test
    • Try Unit test
    • Passing Unit test

Basic Usage

@Api // Only set this class as API
export class MyClass {
    @HttpGet('/profile/:id/') // The route will be: /profile/:id
    public profile () {}
}

Basic Usage

@Api('users/') // Set this class as API and set root route
export class MyClass {
    @HttpGet('/profile/:id/') // The route will be: /users/profile/:id
    public profile () {}
}

Manifiest Usage

First, set "http.root" on manifiest.json
src/manifiest.json

{
    "http": {
        "root" : "/my/awesome/api/"
    }
}

src/controllers/MyClass.controller.ts

@Api('users/', true) // Set this class as API and set root route
export class MyClassController extends Controller {
    @HttpGet('/profile/:id/') // The route will be: /my/awesome/api/users/profile/:id
    public profile () {}
}

New Feature: Annotation @HttpExpect

With the @HttpExpect annotation you will be able to define the necessary rules to execute a service safely, validating each step.

  • Multiple Rules
  • @HttpExpect validate as custom validation function
  • @HttpExpect message as custom message error
  • @HttpExpect in
    • query - Query String
    • path - path url
    • cookie - Cookies
    • header - Headers
    • body - POST/PUT data
      • Conten-Type application/json
      • Conten-Type application/x-www-form-urlencoded
  • @HttpExpect type
    • Equal to String
    • Equal to Number
    • Equal to Object
    • Equal to Array
  • Create Unit Test
    • Try Unit Test
    • Passing Unit Test

@HttpExpect Options

Option Possible Values Optional Default Value Data Type
in 'header', 'path', 'query', 'body', 'cookie' query string
type Object, String, Array and Number String Constructor
required true, false false boolean
default undefined string, boolean, array, number

Example

@Api
export class MyController {
    @HttpGet()
    @HttpExpect({
        'id' : {
            type : String,
            in: 'query'
            required: true,
            default:0
        }
    })
    public get () {
        return this.httpOk(this.queryString().id);
    }
}

Alternative Example

@Api
export class MyController {
    @HttpGet()
    @HttpExpect({
        'id' : Number  // Default in query as Number
    })
    public get () {
        return this.httpOk(this.queryString().id);
    }
}

Providers

Providers

  • MySQL
  • MariaDB
  • Postgres
  • SQLite
  • Microsoft SQL Server
  • Mongo
  • Microsoft Access
  • Oracle
  • Cassandra
  • Redis
  • CouchDB
  • PouchDB
  • LokiJS
  • Azure Cosmos DB
  • Amazon DynamoDB
  • Amazon SES
  • SMTP Client
  • Static Files
  • OneSignal Client

ORM's

  • Sequelize
  • Mongoose
  • node-orm2

Auth

  • OAuth1
  • OAuth2
  • Basic Auth
  • JWT
  • OAuth2
  • ApiKey

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Encapsulate methods

We need encapsulate methods/functions to prevent errors and catch it before continue execution.

  • Encapsulate execution of method
  • Catch unhandledRejection
  • Custom Exception to Http Responses

An in-range update of snyk is breaking the build 🚨

Version 1.89.1 of snyk was just published.

Branch Build failing 🚨
Dependency snyk
Current Version 1.89.0
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

snyk is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/codeship: Build succeeded (Details).
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes v1.89.1

Bug Fixes

  • Add cliMessage passing to all pkg managers (a54c615)
  • enhance user errors to point to snyk docs (f0a43a5)
  • handle license issues better (2e20440)
Commits

The new version differs by 4 commits.

  • 2e20440 fix: handle license issues better
  • d325836 tests: Update tests
  • f0a43a5 fix: enhance user errors to point to snyk docs
  • a54c615 fix: Add cliMessage passing to all pkg managers

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

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.