Git Product home page Git Product logo

thinkjs's Introduction

Coverage Status


NPM version travis-ci Coverage Status

简体中文文档

Introduction

As a Node.js MVC framework, ThinkJS 2.0 had completelly been rewritten with brand-new ECMAScript 6/7 features. By using ES7's async/await or ES6's Generator Function features, ThinkJS 2.0 could thoroughly solve the asynchronous nesting problem within Node.js. Also, ThinkJS 2.0 has designed by absorb the concepts and ideas from many frameworks around the world, so developing Node.js projects with ThinkJS would be more simple and efficient than ever.

It's the trend that using ES6/7 features to develop projects thanks to the high development efficiency. The new version of Node.js has improved to support many ES6 featrues, though some features have not been supported until now, and for those features we can use Babel to compile the code.

//user controller, home/controller/user.js
export default class extends think.controller.base {
  //login action
  async loginAction(self){
    //if it's GET method,display the login page
    if(this.isGet()){
      return this.display();
    }
    //here, we can use POST retrieve all data, and the data have been validated in the logic
    let data = this.post();
    let md5 = think.md5('think_' + data.pwd);
    //user name and encrypted password are used to match the recod in the database
    let result = await this.model('user').where({name: data.name, pwd: md5}).find();
    //if nothing matched, mean user name or password is/or all are incorrect
    if(think.isEmpty(result)){
      return this.fail('login fail');
    }
    //obtain the user infomation, and write to the seesion
    await this.session('userInfo', result);
    return this.success();
  }
}

With the help of Babel compiling, we can use the ES6/7 features bodly, and then the code can running in the Node.js 0.12.0+ environment stably.

Features

  • Developing projects using all the new features of ES6/7.
  • Supporting various project construct forms and environments.
  • Supporting Mysql, MongoDB and SQLite databases.
  • Automatically updating code, no need to restart Node.js server.
  • Supporting various WebSocket libraries such as socket.io and SockJS.
  • Supporting various Sessions such as Memory, File, Db and Redis.
  • Supporting various Caches such as Memory, File, Redis and Memcache.
  • Supporting various template engines such as ejs, jade, swig and numjucks.
  • Supporting AOP, and magic methods such as __before and __after.
  • Supporting 400, 404, 500 and 503 error pages.
  • Supporting command-line call and crontab timing task execution.
  • Multiple Hooks and Middlewares.
  • Logs with details, such as requests, errors, performance, etc.
  • Supporting commands that could auto create REST API.
  • Supporting internationalization and multiple themes.
  • 1500+ test cases, code coverage greater than 95%.

Installation

npm install -g thinkjs

Create Application

thinkjs new project_path --es6

http://www.thinkjs.org/doc/create_project.html

Start Application

cd project_path;
npm start

Documentation

https://thinkjs.org/

License

MIT

thinkjs's People

Contributors

welefen avatar maxzhang avatar rayi avatar akira-cn avatar jedmeng avatar snadn avatar qgy18 avatar alphatr avatar wavelynn avatar jiangyuan avatar jacksontian avatar leizongmin avatar pjk420838945 avatar

Watchers

 avatar

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.