DEV Community

zeronon2
zeronon2

Posted on

Getting started FeathersJS

Feathers is a real-time, micro-service web framework for NodeJS that gives you control over your data via RESTful resources, sockets and flexible plug-ins.

install featherjs/cli

npm install @feathersjs/cli -g
Enter fullscreen mode Exit fullscreen mode

Generate a feathers back-end API server

feathers generate app
Enter fullscreen mode Exit fullscreen mode

Image description

Open file config and setup database

backend/config/default.json

Image description

create service

feathersjs generate service
Enter fullscreen mode Exit fullscreen mode

Image description

set up model

// See https://sequelize.org/master/manual/model-basics.html
// for more of what you can do here.
const Sequelize = require('sequelize');
const DataTypes = Sequelize.DataTypes;

module.exports = function (app) {
  const sequelizeClient = app.get('sequelizeClient');
  const aboutUs = sequelizeClient.define('about_us', {
    text: {
      type: DataTypes.STRING,
      allowNull: false
    }
  }, {
    hooks: {
      beforeCount(options) {
        options.raw = true;
      }
    }
  });

  // eslint-disable-next-line no-unused-vars
  aboutUs.associate = function (models) {
    // Define associations here
    // See https://sequelize.org/master/manual/assocs.html
  };

  return aboutUs;
};
Enter fullscreen mode Exit fullscreen mode

get data form database

Image description

Top comments (0)