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

thinkjs

Package Overview
Dependencies
Maintainers
1
Versions
240
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thinkjs

ThinkJS - Use full ES6/7 features to develop web applications, Support TypeScript

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Coverage Status


NPM version travis-ci Coverage Status

简体中文文档

Introduction

As a Node.js MVC framework, ThinkJS 2.0 has completely 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 absorbing the concepts and ideas of many frameworks around the world, so developing Node.js projects with ThinkJS would be more simple and efficient than ever.

It's a 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/7 features, 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 boldly, and then the code can run in the Node.js 0.12.0+ environment stably.

Features

  • Developing projects using all the new features of ES6/7.
  • Auto compiling & auto hot reload when file changed, no need to restart Node.js server.
  • Supporting TypeScript.
  • Supporting various project construct forms and environments.
  • Supporting MySQL, MongoDB, PostgreSQL and SQLite databases.
  • 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 multistage Controller.
  • 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 automatically create REST API.
  • Supporting internationalization and multiple themes.
  • 1700+ test cases, code coverage greater than 95%.

Installation

npm install -g thinkjs

Create Application

thinkjs new project_path --es6

Install dependencies

npm install

Start Application

npm start

You will see some messages on console like :

[2016-01-12 15:09:51] [THINK] Server running at http://127.0.0.1:8360/
[2016-01-12 15:09:51] [THINK] ThinkJS Version: 2.1.0
[2016-01-12 15:09:51] [THINK] Cluster Status: closed
[2016-01-12 15:09:51] [THINK] WebSocket Status: closed
[2016-01-12 15:09:51] [THINK] File Auto Compile: true
[2016-01-12 15:09:51] [THINK] File Auto Reload: true
[2016-01-12 15:09:51] [THINK] App Enviroment: development

Documentation

https://thinkjs.org/en

License

MIT

Keywords

FAQs

Package last updated on 13 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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