Miss any of our Open RFC calls?Watch the recordings here! »

node-core

0.1.11 • Public • Published

Introduction

node-core is a Node.js framework based on Alibaba's Egg.js.

Install

$ npm install --save node-core

Example

Please visit a full example here.

Questions & Suggestions

Please open an issue here.

Supported plugins

References

Usage

Create articles model:

// app/model/articles.js
module.exports = app => {
  const {STRING, TEXT, INTEGER} = app.Sequelize
 
  return app.model.define('articles', {
    id: {
      type: INTEGER(8),
      primaryKey: true,
      autoIncrement: true,
      allowNull: false
    },
    author: {
      type: STRING(50),
      allowNull: true
    },
    title: {
      type: STRING(200),
      allowNull: false
    },
    subtitle: {
      type: STRING(200),
      allowNull: true
    },
    description: {
      type: TEXT('tiny'),
    },
    content: {
      type: TEXT('long'),
      allowNull: true
    },
    image: {
      type: INTEGER(8),
      allowNull: true
    },
    category_id: {
      type: INTEGER,
      allowNull: true
    }
  })
}

Create articles service:

// app/service/articles.js
module.exports = app => {
  return class extends app.Service {
    constructor (ctx) {
      super(ctx)
 
      this.module = 'articles'
    }
  }
}

Create articles controller:

// app/controller/articles.js
module.exports = app => {
  return class extends app.Controller {
    constructor (ctx) {
      super(ctx)
 
      this.module = 'articles'
    }
  }
}

Install

npm i node-cor[email protected]

Version

0.1.11

License

MIT

Last publish

Collaborators

  • avatar