DEV Community

zeronon2
zeronon2

Posted on

3 2

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

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More