npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

user-roles-permission

v1.0.0

Published

Create a Node.js Express RESTful APIs using sequelize

Downloads

14

Readme

//import file need follo this

  1. env .env.local 2.migrations file A. 20230600000001-create-refresh-token.js const config = require('../src/config/vars'); /** @type {import('sequelize-cli').Migration} */ module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable( 'refreshToken', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER, }, userId: { allowNull: false, type: Sequelize.INTEGER, }, token: { allowNull: false, type: Sequelize.STRING, }, createdAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, updatedAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, }, { schema: config.db.schema, }, { freezeTableName: true, } ); }, async down(queryInterface) { await queryInterface.dropTable('refreshToken'); }, }; B. 20230600000002-create-users.js

    const config = require('../src/config/vars'); /** @type {import('sequelize-cli').Migration} */

module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable( 'users', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER, }, userName: { type: Sequelize.STRING, }, password: { type: Sequelize.STRING, }, email: { type: Sequelize.STRING, }, mobile: { type: Sequelize.STRING, validate: { is: /^\d{10}$/, }, }, firstName: { type: Sequelize.STRING, }, lastName: { type: Sequelize.STRING, }, fatherName: { type: Sequelize.STRING, }, dob: { type: Sequelize.DATEONLY, }, gender: { type: Sequelize.ENUM('Male', 'Female', 'Prefer not to say'), }, street1: { type: Sequelize.STRING, }, street2: { type: Sequelize.STRING, }, pincode: { type: Sequelize.STRING, }, country: { type: Sequelize.STRING, }, state: { type: Sequelize.STRING, }, city: { type: Sequelize.STRING, }, isAdmin: { type: Sequelize.BOOLEAN, }, userStatus: { type: Sequelize.STRING, }, isTrash: { type: Sequelize.BOOLEAN, }, inviteDate: { type: Sequelize.DATE, }, resendLinkCount: { type: Sequelize.INTEGER, }, isResetByMail: { type: Sequelize.BOOLEAN, }, resetMailTime: { type: Sequelize.DATE, }, privacyURL: { type: Sequelize.STRING, }, imageName: { type: Sequelize.STRING, }, created_by: { type: Sequelize.INTEGER, references: { model: 'users', key: 'id', }, onDelete: 'CASCADE', }, updated_by: { type: Sequelize.INTEGER, references: { model: 'users', key: 'id', }, onDelete: 'CASCADE', }, createdAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, updatedAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, }, { schema: config.db.schema, freezeTableName: true, } ); }, async down(queryInterface) { await queryInterface.dropTable('users'); }, };

C. 20230600000003-create-modules.js

const config = require('../src/config/vars'); /** @type {import('sequelize-cli').Migration} */ module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable( 'modules', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER, }, name: { type: Sequelize.STRING, }, key: { type: Sequelize.STRING, }, created_by: { type: Sequelize.INTEGER, references: { model: 'users', key: 'id', }, onDelete: 'CASCADE', }, updated_by: { type: Sequelize.INTEGER, references: { model: 'users', key: 'id', }, onDelete: 'CASCADE', }, isActive: { allowNull: false, type: Sequelize.BOOLEAN, }, orderId: { allowNull: false, type: Sequelize.INTEGER, }, isCard: { allowNull: false, type: Sequelize.BOOLEAN, }, cardColor: { allowNull: false, type: Sequelize.STRING, }, cardBg: { allowNull: false, type: Sequelize.STRING, }, redirectURL: { allowNull: false, type: Sequelize.STRING, }, createdAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, updatedAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, }, { schema: config.db.schema, }, { freezeTableName: true, } ); }, async down(queryInterface) { await queryInterface.dropTable('modules'); }, };

D. 20230600000004-create-features.js

const config = require('../src/config/vars'); /** @type {import('sequelize-cli').Migration} */ module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable( 'features', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER, }, name: { type: Sequelize.STRING, }, key: { type: Sequelize.STRING, }, group_id: { type: Sequelize.INTEGER, }, isProtected: { type: Sequelize.BOOLEAN, }, orderId: { type: Sequelize.INTEGER, }, created_by: { type: Sequelize.INTEGER, references: { model: 'users', key: 'id', }, onDelete: 'CASCADE', }, updated_by: { type: Sequelize.INTEGER, references: { model: 'users', key: 'id', }, onDelete: 'CASCADE', }, isActive: { type: Sequelize.BOOLEAN, }, createdAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, updatedAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, }, { schema: config.db.schema, }, { freezeTableName: true, } ); }, async down(queryInterface) { await queryInterface.dropTable('features'); }, };

E. 20230600000005-create-module-features.js

const config = require('../src/config/vars'); /** @type {import('sequelize-cli').Migration} */ module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable( 'moduleFeatures', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER, }, module_id: { type: Sequelize.INTEGER, references: { model: 'modules', key: 'id', }, onDelete: 'CASCADE', }, feature_id: { type: Sequelize.INTEGER, references: { model: 'features', key: 'id', }, onDelete: 'CASCADE', }, createdAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, updatedAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, }, { schema: config.db.schema, }, { freezeTableName: true, } ); }, async down(queryInterface) { await queryInterface.dropTable('moduleFeatures'); }, };

F. 20230600000006-create-roles.js

const config = require('../src/config/vars'); /** @type {import('sequelize-cli').Migration} */ module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable( 'roles', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER, }, name: { type: Sequelize.STRING, }, key: { type: Sequelize.STRING, }, created_by: { type: Sequelize.INTEGER, references: { model: 'users', key: 'id', }, onDelete: 'CASCADE', }, updated_by: { type: Sequelize.INTEGER, references: { model: 'users', key: 'id', }, onDelete: 'CASCADE', }, module_id: { type: Sequelize.INTEGER, references: { model: 'modules', key: 'id', }, onDelete: 'CASCADE', }, isActive: { type: Sequelize.BOOLEAN, }, createdAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, updatedAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, }, { schema: config.db.schema, }, { freezeTableName: true, } ); }, async down(queryInterface) { await queryInterface.dropTable('roles'); }, };

G. 20230600000007-create-role-features.js

const config = require('../src/config/vars'); /** @type {import('sequelize-cli').Migration} */ module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable( 'roleFeatures', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER, }, role_id: { type: Sequelize.INTEGER, references: { model: 'roles', key: 'id', }, onDelete: 'CASCADE', }, feature_id: { type: Sequelize.INTEGER, references: { model: 'features', key: 'id', }, onDelete: 'CASCADE', }, createdAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, updatedAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, }, { schema: config.db.schema, }, { freezeTableName: true, } ); }, async down(queryInterface) { await queryInterface.dropTable('roleFeatures'); }, };

H. 20230600000008-create-user-module-roles.js

const config = require('../src/config/vars'); /** @type {import('sequelize-cli').Migration} */ module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable( 'userModuleRoles', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER, }, user_id: { type: Sequelize.INTEGER, references: { model: 'users', key: 'id', }, onDelete: 'CASCADE', }, module_id: { type: Sequelize.INTEGER, references: { model: 'modules', key: 'id', }, onDelete: 'CASCADE', }, role_id: { type: Sequelize.INTEGER, references: { model: 'roles', key: 'id', }, onDelete: 'CASCADE', }, created_by: { type: Sequelize.INTEGER, references: { model: 'users', key: 'id', }, onDelete: 'CASCADE', }, updated_by: { type: Sequelize.INTEGER, references: { model: 'users', key: 'id', }, onDelete: 'CASCADE', }, createdAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, updatedAt: { allowNull: false, type: Sequelize.DATE, defaultValue: new Date(), }, }, { schema: config.db.schema, }, { freezeTableName: true, } ); }, async down(queryInterface) { await queryInterface.dropTable('userModuleRoles'); }, };

// 3. models File A. features.js const { Model } = require('sequelize'); const config = require('../src/config/vars');

        module.exports = (sequelize, DataTypes) => {
        class features extends Model {}
        features.init(
            {
            name: DataTypes.STRING,
            key: DataTypes.STRING,
            group_id: DataTypes.INTEGER,
            isProtected: DataTypes.BOOLEAN,
            orderId: DataTypes.INTEGER,
            created_by: DataTypes.INTEGER,
            updated_by: DataTypes.INTEGER,
            isActive: DataTypes.BOOLEAN,
            },
            {
            sequelize,
            modelName: 'features',
            schema: config.db.schema,
            freezeTableName: true,
            }
        );
        features.associate = function (models) {
            features.belongsToMany(models.roles, {
            through: 'roleFeatures',
            as: 'roles',
            foreignKey: 'feature_id',
            });
            features.belongsToMany(models.modules, {
            through: 'moduleFeatures',
            as: 'modules',
            foreignKey: 'feature_id',
            });
            features.belongsTo(models.users, { foreignKey: 'created_by', as: 'createUser' });
            features.belongsTo(models.users, { foreignKey: 'updated_by', as: 'updateUser' });
            // features.belongsTo(models.group, { foreignKey: 'group_id', as: 'group' });
        };
        return features;
        };

                B. index.js

                            /* eslint-disable global-require */
                /* eslint-disable import/no-dynamic-require */
                /* eslint-disable security/detect-non-literal-require */
                const fs = require('fs');
                const path = require('path');
                const Sequelize = require('sequelize');

                const basename = path.basename(__filename);
                const config = require(`../src/config/vars.js`).db;

                const { db } = require('../src/config/vars');

                const sequelize = new Sequelize(config.database, config.username, config.password, {
                host: config.host,
                dialect: config.dialect,
                schema: config.schema,
                logging: false,
                });

                fs.readdirSync(__dirname)
                .filter((file) => {
                    return file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js';
                })
                .forEach((file) => {
                    const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
                    db[model.name] = model;
                });

                Object.keys(db).forEach((modelName) => {
                if (db[modelName].associate) {
                    db[modelName].associate(db);
                }
                });

                db.sequelize = sequelize;
                db.Sequelize = Sequelize; 

                module.exports = db;


           C. modulefeatures.js

            const { Model } = require('sequelize');
            const config = require('../src/config/vars');

            module.exports = (sequelize, DataTypes) => {
            class moduleFeatures extends Model {}
            moduleFeatures.init(
                {
                module_id: DataTypes.INTEGER,
                feature_id: DataTypes.INTEGER,
                },
                {
                sequelize,
                modelName: 'moduleFeatures',
                schema: config.db.schema,
                freezeTableName: true,
                }
            );
            moduleFeatures.associate = function (models) {
                moduleFeatures.belongsTo(models.modules, { foreignKey: 'module_id', as: 'modules' });
                moduleFeatures.belongsTo(models.features, { foreignKey: 'feature_id', as: 'features' });
            };
            return moduleFeatures;
            };
        D.Modules.js

            const { Model } = require('sequelize');
            const config = require('../src/config/vars');

            module.exports = (sequelize, DataTypes) => {
            class modules extends Model {}
            modules.init(
                {
                name: DataTypes.STRING,
                key: DataTypes.STRING,
                created_by: DataTypes.INTEGER,
                updated_by: DataTypes.INTEGER,
                isActive: DataTypes.BOOLEAN,
                orderId: DataTypes.INTEGER,
                isCard: DataTypes.BOOLEAN,
                cardColor: DataTypes.STRING,
                cardBg: DataTypes.STRING,
                redirectURL: DataTypes.STRING,
                },
                {
                sequelize,
                modelName: 'modules',
                schema: config.db.schema,
                freezeTableName: true,
                }
            );
            modules.associate = function (models) {
                modules.belongsToMany(models.features, {
                through: 'moduleFeatures',
                as: 'features',
                foreignKey: 'module_id',
                });
                modules.hasMany(models.userModuleRoles, { foreignKey: 'module_id', as: 'userModuleRoles' });
                modules.belongsTo(models.users, { foreignKey: 'created_by', as: 'createUser' });
                modules.belongsTo(models.users, { foreignKey: 'updated_by', as: 'updateUser' });
                modules.hasMany(models.roles, { foreignKey: 'module_id', as: 'roles' });
                // modules.hasMany(models.jobs, { foreignKey: 'department_id', as: 'departmentJob' });
            };
            return modules;
            };

        E.refreshtoken.js

            const { Model } = require('sequelize');
            const config = require('../src/config/vars');

            module.exports = (sequelize, DataTypes) => {
            class refreshToken extends Model {}
            refreshToken.init(
                {
                userId: DataTypes.INTEGER,
                token: DataTypes.STRING,
                },
                {
                sequelize,
                modelName: 'refreshToken',
                schema: config.db.schema,
                freezeTableName: true,
                }
            );
            return refreshToken;
            };

        F. rolefeatures.js

        const { Model } = require('sequelize');
        const config = require('../src/config/vars');

        module.exports = (sequelize, DataTypes) => {
        class roleFeatures extends Model {}
        roleFeatures.init(
            {
            role_id: DataTypes.INTEGER,
            feature_id: DataTypes.INTEGER,
            },
            {
            sequelize,
            modelName: 'roleFeatures',
            schema: config.db.schema,
            freezeTableName: true,
            }
        );
        roleFeatures.associate = function (models) {
            roleFeatures.belongsTo(models.features, { foreignKey: 'feature_id', as: 'features' });
            roleFeatures.belongsTo(models.roles, { foreignKey: 'role_id', as: 'roles' });
        };
        return roleFeatures;
        };

        G. roles 

        const { Model } = require('sequelize');
        const config = require('../src/config/vars');

        module.exports = (sequelize, DataTypes) => {
        class roles extends Model {}
        roles.init(
            {
            name: DataTypes.STRING,
            key: DataTypes.STRING,
            created_by: DataTypes.INTEGER,
            updated_by: DataTypes.INTEGER,
            module_id: DataTypes.INTEGER,
            isActive: DataTypes.BOOLEAN,
            },
            {
            sequelize,
            modelName: 'roles',
            schema: config.db.schema,
            freezeTableName: true,
            }
        );
        roles.associate = function (models) {
            roles.belongsToMany(models.features, {
            through: 'roleFeatures',
            as: 'features',
            foreignKey: 'role_id',
            });
            roles.hasMany(models.userModuleRoles, { foreignKey: 'role_id', as: 'userModuleRoles' });
            roles.belongsTo(models.users, { foreignKey: 'created_by', as: 'userCreate' });
            roles.belongsTo(models.users, { foreignKey: 'updated_by', as: 'userUpdate' });
            roles.belongsTo(models.modules, { foreignKey: 'module_id', as: 'modules' });
        };
        return roles;
        };

        H.userauthoraccess.js

             const { Model } = require('sequelize');
            const config = require('../src/config/vars');

            module.exports = (sequelize, DataTypes) => {
            class userAuthorAccess extends Model {}
            userAuthorAccess.init(
                {
                user_id: DataTypes.INTEGER,
                user_accessId: DataTypes.INTEGER,
                },
                {
                sequelize,
                modelName: 'userAuthorAccess',
                schema: config.db.schema,
                freezeTableName: true,
                }
            );
            userAuthorAccess.associate = function (models) {
                userAuthorAccess.belongsTo(models.users, { foreignKey: 'user_id', as: 'user' });
                // userAuthorAccess.belongsTo(models.authorAccess, { foreignKey: 'user_accessId', as: 'author' });
            };
            return userAuthorAccess;
            };
       I. usermoduleroles.js

                const { Model } = require('sequelize');
                const config = require('../src/config/vars');

                module.exports = (sequelize, DataTypes) => {
                class userModuleRoles extends Model {}
                userModuleRoles.init(
                    {
                    user_id: DataTypes.INTEGER,
                    module_id: DataTypes.INTEGER,
                    role_id: DataTypes.INTEGER,
                    created_by: DataTypes.INTEGER,
                    updated_by: DataTypes.INTEGER,
                    },
                    {
                    sequelize,
                    modelName: 'userModuleRoles',
                    schema: config.db.schema,
                    freezeTableName: true,
                    }
                );
                userModuleRoles.associate = function (models) {
                    userModuleRoles.belongsTo(models.modules, { foreignKey: 'module_id', as: 'module' });
                    userModuleRoles.belongsTo(models.roles, { foreignKey: 'role_id', as: 'role' });
                    userModuleRoles.belongsTo(models.users, { foreignKey: 'user_id', as: 'user' });
                    userModuleRoles.belongsTo(models.users, { foreignKey: 'created_by', as: 'createUser' });
                    userModuleRoles.belongsTo(models.users, { foreignKey: 'updated_by', as: 'updateUser' });
                };
                return userModuleRoles;
                };

        J. users.js
            const { Model } = require('sequelize');
            const config = require('../src/config/vars');

            module.exports = (sequelize, DataTypes) => {
            class users extends Model {}
            users.init(
                {
                userName: DataTypes.STRING,
                password: DataTypes.STRING,
                email: DataTypes.STRING,
                mobile: DataTypes.STRING,
                firstName: DataTypes.STRING,
                lastName: DataTypes.STRING,
                fatherName: DataTypes.STRING,
                dob: DataTypes.DATEONLY,
                gender: DataTypes.ENUM('Male', 'Female', 'Prefer not to say'),
                street1: DataTypes.STRING,
                street2: DataTypes.STRING,
                pincode: DataTypes.STRING,
                country: DataTypes.STRING,
                state: DataTypes.STRING,
                city: DataTypes.STRING,
                isAdmin: DataTypes.BOOLEAN,
                userStatus: DataTypes.STRING,
                isTrash: DataTypes.BOOLEAN,
                inviteDate: DataTypes.DATE,
                resendLinkCount: DataTypes.INTEGER,
                isResetByMail: DataTypes.BOOLEAN,
                resetMailTime: DataTypes.DATE,
                privacyURL: DataTypes.STRING,
                imageName: DataTypes.STRING,
                created_by: DataTypes.INTEGER,
                updated_by: DataTypes.INTEGER,
                // bio: DataTypes.STRING,
                // authorStatus: DataTypes.STRING,
                // executiveId: DataTypes.INTEGER,
                },
                {
                sequelize,
                modelName: 'users',
                schema: config.db.schema,
                freezeTableName: true,
                }
            );
            users.associate = function (models) {
                users.hasMany(models.userModuleRoles, { foreignKey: 'user_id', as: 'user' });
                users.hasMany(models.userModuleRoles, { foreignKey: 'created_by', as: 'userCreate' });
                users.hasMany(models.userModuleRoles, { foreignKey: 'updated_by', as: 'userUpdate' });

                users.hasMany(models.features, { foreignKey: 'created_by', as: 'featureCreate' });
                users.hasMany(models.features, { foreignKey: 'updated_by', as: 'featureUpdate' });

                users.hasMany(models.modules, { foreignKey: 'created_by', as: 'moduleCreate' });
                users.hasMany(models.modules, { foreignKey: 'updated_by', as: 'moduleUpdate' });

                users.hasMany(models.roles, { foreignKey: 'created_by', as: 'roleCreate' });
                users.hasMany(models.roles, { foreignKey: 'updated_by', as: 'roleUpdate' });

                users.belongsTo(models.users, { foreignKey: 'created_by', as: 'createBy' });
                users.belongsTo(models.users, { foreignKey: 'updated_by', as: 'updateBy' });

            };
            return users;
            };
  1. seeders file

     A.20231016055331-users.js
    
             const jwt = require('jsonwebtoken');
             const { Sequelize } = require('sequelize');
             const config = require('../src/config/vars');
             /** @type {import('sequelize-cli').Migration} */
             const encryptedPassword = jwt.sign(
             {
                 password: 'Demo@123',
             },
             config.app.accesstoken
             );
             module.exports = {
             async up(queryInterface) {
                 return queryInterface.bulkInsert(
                 { tableName: 'users', schema: config.db.schema },
                 [
                     {
                     userName: 'Sheshiadmin',
                     email: '[email protected]',
                     password: encryptedPassword,
                     mobile: '9855433254',
                     firstName: 'Fernandus',
                     lastName: 'Ferro',
                     gender: 'Male',
                     pincode: '560041',
                     country: 'India',
                     state: 'Karnataka',
                     city: 'Bangalore South',
                     isResetByMail: false,
                     isAdmin: true,
                     userStatus: 'Active',
                     isTrash: false,
                     createdAt: Sequelize.literal('NOW()'),
                     updatedAt: Sequelize.literal('NOW()'),
                     },
                     {
                     userName: 'Jothi2810',
                     email: '[email protected]',
                     password: encryptedPassword,
                     mobile: '9855433200',
                     firstName: 'Jothi',
                     lastName: 'Krishana',
                     gender: 'Male',
                     pincode: '560041',
                     country: 'India',
                     state: 'Karnataka',
                     city: 'Bangalore South',
                     isResetByMail: false,
                     isAdmin: false,
                     userStatus: 'Active',
                     isTrash: false,
                     createdAt: Sequelize.literal('NOW()'),
                     updatedAt: Sequelize.literal('NOW()'),
                     },
                 ],
                 {}
                 );
             },
    
             async down(queryInterface) {
                 return queryInterface.bulkDelete({ tableName: 'users', schema: config.db.schema }, null, {});
             },
             };
    
    
             B.20231016055332-modules.js
    
                     const config = require('../src/config/vars');
                     /** @type {import('sequelize-cli').Migration} */
                     module.exports = {
                     async up(queryInterface) {
                         return queryInterface.bulkInsert(
                         { tableName: 'modules', schema: config.db.schema },
                         [
                             {
                             name: 'Sales',
                             key: 'sales',
                             created_by: 1,
                             updated_by: 1,
                             isActive: true,
                             orderId: 1,
                             isCard: true,
                             cardColor: '',
                             cardBg: '',
                             redirectURL: '',
                             },
                             {
                             name: 'Marketing',
                             key: 'marketing',
                             created_by: 1,
                             updated_by: 1,
                             isActive: true,
                             orderId: 2,
                             isCard: true,
                             cardColor: '',
                             cardBg: '',
                             redirectURL: '',
                             },
                             {
                             name: 'Product',
                             key: 'product',
                             created_by: 1,
                             updated_by: 1,
                             isActive: true,
                             orderId: 3,
                             isCard: true,
                             cardColor: '',
                             cardBg: '',
                             redirectURL: '',
                             },
                             {
                             name: 'Design',
                             key: 'design',
                             created_by: 1,
                             updated_by: 1,
                             isActive: true,
                             orderId: 4,
                             isCard: true,
                             cardColor: '',
                             cardBg: '',
                             redirectURL: '',
                             },
                             {
                             name: 'Customer Success',
                             key: 'customerSuccess',
                             created_by: 1,
                             updated_by: 1,
                             isActive: true,
                             orderId: 5,
                             isCard: true,
                             cardColor: '',
                             cardBg: '',
                             redirectURL: '',
                             },
                             {
                             name: 'Development',
                             key: 'development',
                             created_by: 1,
                             updated_by: 1,
                             isActive: true,
                             orderId: 6,
                             isCard: true,
                             cardColor: '',
                             cardBg: '',
                             redirectURL: '',
                             },
                             {
                             name: 'Web Content',
                             key: 'webContent',
                             created_by: 1,
                             updated_by: 1,
                             isActive: true,
                             orderId: 7,
                             isCard: true,
                             cardColor: '',
                             cardBg: '',
                             redirectURL: '',
                             },
                             {
                             name: 'Human Resources',
                             key: 'humanResources',
                             created_by: 1,
                             updated_by: 1,
                             isActive: true,
                             orderId: 8,
                             isCard: true,
                             cardColor: '',
                             cardBg: '',
                             redirectURL: '',
                             },
                         ],
                         {}
                         );
                     },
    
                     async down(queryInterface) {
                         return queryInterface.bulkDelete({ tableName: 'modules', schema: config.db.schema }, null, {});
                     },
                     };
    
         C.20231016055333-features.js
    
                 const { Sequelize } = require('sequelize');
                 const config = require('../src/config/vars');
                 /** @type {import('sequelize-cli').Migration} */
                 module.exports = {
                 async up(queryInterface) {
                     return queryInterface.bulkInsert(
                     { tableName: 'features', schema: config.db.schema },
                     [
                         {
                         name: 'Add Users',
                         key: 'addUsers',
                         isActive: true,
                         group_id: 1,
                         isProtected: true,
                         orderId: 1,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Add/Edit Roles',
                         key: 'addeditRoles',
                         isActive: true,
                         group_id: 1,
                         isProtected: true,
                         orderId: 2,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Add Organization',
                         key: 'addOrganization',
                         isActive: true,
                         group_id: 2,
                         isProtected: false,
                         orderId: 3,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Extend Plan',
                         key: 'extendPlan',
                         isActive: true,
                         group_id: 2,
                         isProtected: false,
                         orderId: 4,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Upgrade Plan',
                         key: 'upgradePlan',
                         isActive: true,
                         group_id: 2,
                         isProtected: false,
                         orderId: 5,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Block Organization',
                         key: 'blockOrganization',
                         isActive: true,
                         group_id: 2,
                         isProtected: false,
                         orderId: 6,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Unblock Organization',
                         key: 'unblockOrganization',
                         isActive: true,
                         group_id: 2,
                         isProtected: false,
                         orderId: 7,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Reset Password',
                         key: 'resetPassword',
                         isActive: true,
                         group_id: 2,
                         isProtected: false,
                         orderId: 8,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Add Plans',
                         key: 'addPlans',
                         isActive: true,
                         group_id: 3,
                         isProtected: false,
                         orderId: 9,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Activate / Deactivate Plan',
                         key: 'activateDeactivatePlan',
                         isActive: true,
                         group_id: 3,
                         isProtected: false,
                         orderId: 10,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Plan Search',
                         key: 'planSearch',
                         isActive: true,
                         group_id: 3,
                         isProtected: false,
                         orderId: 11,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Plan Downloads',
                         key: 'planDownloads',
                         isActive: true,
                         group_id: 3,
                         isProtected: false,
                         orderId: 12,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Organization Search',
                         key: 'organizationSearch',
                         isActive: true,
                         group_id: 2,
                         isProtected: false,
                         orderId: 13,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Organization Downloads',
                         key: 'organizationDownloads',
                         isActive: true,
                         group_id: 2,
                         isProtected: false,
                         orderId: 14,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Others',
                         key: 'others',
                         isActive: true,
                         group_id: 1,
                         isProtected: false,
                         orderId: 15,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Delete Role',
                         key: 'deleteRole',
                         isActive: true,
                         group_id: 1,
                         isProtected: true,
                         orderId: 2,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Edit Users',
                         key: 'editUsers',
                         isActive: true,
                         group_id: 1,
                         isProtected: true,
                         orderId: 2,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Delete Users',
                         key: 'deleteUsers',
                         isActive: true,
                         group_id: 1,
                         isProtected: true,
                         orderId: 2,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Permanent Delete',
                         key: 'permanentDelete',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 16,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'View Author',
                         key: 'viewAuthor',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 17,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Add Author',
                         key: 'addAuthor',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 18,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Edit Author Self',
                         key: 'editAuthorSelf',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 19,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Add Category',
                         key: 'addCategory',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 20,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Edit Category',
                         key: 'editCategory',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 21,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Draft Publish',
                         key: 'draftPublish',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 22,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Publish Draft',
                         key: 'publishDraft',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 23,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Delete Draft',
                         key: 'deleteDraft',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 24,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Edit Draft Any',
                         key: 'editDraftAny',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 25,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Add Draft',
                         key: 'addDraft',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 26,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'View Published',
                         key: 'viewPublished',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 27,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Draft Deleted Any',
                         key: 'draftDeletedAny',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 28,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Draft Deleted Self',
                         key: 'draftDeletedSelf',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 29,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Edit Draft Self',
                         key: 'editDraftSelf',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 30,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Author Status Update',
                         key: 'authorStatusUpdate',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 31,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Edit Author Any',
                         key: 'editAuthorAny',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 32,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Add Rating Feature',
                         key: 'addRatingFeature',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 33,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Delete Category',
                         key: 'deleteCategory',
                         isActive: true,
                         group_id: 4,
                         isProtected: false,
                         orderId: 34,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Add Applicant',
                         key: 'addApplicant',
                         isActive: true,
                         group_id: 6,
                         isProtected: false,
                         orderId: 35,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Change Applicant Status',
                         key: 'changeApplicantStatus',
                         isActive: true,
                         group_id: 6,
                         isProtected: false,
                         orderId: 36,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Edit Application',
                         key: 'editApplication',
                         isActive: true,
                         group_id: 6,
                         isProtected: false,
                         orderId: 37,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Application Download',
                         key: 'applicationDownload',
                         isActive: true,
                         group_id: 6,
                         isProtected: false,
                         orderId: 38,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Download Resume',
                         key: 'downloadResume',
                         isActive: true,
                         group_id: 6,
                         isProtected: false,
                         orderId: 39,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Add Job',
                         key: 'addJob',
                         isActive: true,
                         group_id: 5,
                         isProtected: false,
                         orderId: 40,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Post Job',
                         key: 'postJob',
                         isActive: true,
                         group_id: 5,
                         isProtected: false,
                         orderId: 41,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Close Job',
                         key: 'closeJob',
                         isActive: true,
                         group_id: 5,
                         isProtected: false,
                         orderId: 40,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Job Move To Draft',
                         key: 'jobMoveToDraft',
                         isActive: true,
                         group_id: 5,
                         isProtected: false,
                         orderId: 41,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Delete Job',
                         key: 'deleteJob',
                         isActive: true,
                         group_id: 5,
                         isProtected: false,
                         orderId: 42,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Duplicate Job',
                         key: 'duplicateJob',
                         isActive: true,
                         group_id: 5,
                         isProtected: false,
                         orderId: 43,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Edit Job',
                         key: 'editJob',
                         isActive: true,
                         group_id: 5,
                         isProtected: false,
                         orderId: 44,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                         {
                         name: 'Job Downloads',
                         key: 'jobDownloads',
                         isActive: true,
                         group_id: 5,
                         isProtected: false,
                         orderId: 45,
                         created_by: 1,
                         updated_by: 1,
                         createdAt: Sequelize.literal('NOW()'),
                         updatedAt: Sequelize.literal('NOW()'),
                         },
                     ],
                     {}
                     );
                 },