1.2.0 • Published 3 years ago

npm-hublo-generator v1.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

generator-medgo-suite NPM version Build Status Dependency Status

The Hublo tool suite to help you be more productive

Installation

First, install Yeoman and npm-hublo-generator using npm (we assume you have pre-installed node.js).

npm install -g yo
npm install -g npm-hublo-generator

Then generate files using this generator, use one of these commands

# This creates all the files needed for the generated modules to work properly
# Only run this command once
yo hublo:init

# This creates all the files for a new model
# Router - Validator - Redux Store - Sequelize Model - Interfaces
yo hublo:create <modelName>


# Takes the attributes from the sequelize Model and adds:
# - The sequelize Init call
# - The fields required in the validator
# - The properties in the interface used in the front end
yo hublo:sync <modelName>

Init generated files

Here's all the files generated by the init command. Make sure your folder structer is similar to this or you'll have multiple time the same folder

.
|____server
| |____middleware
| | |____response
| | | |____sendResponse.middleware.ts # Middleware to send a response with a status, messages and data
| | | |____sendData.middleware.ts # Sends just the raw data in the response
| | |____security
| | | |____headerToToken.middleware.ts # Takes the authorization token and puts it in the req object
| | | |____medgoAuth.middleware.ts # Checks if the user is using a medgo access token
| | | |____auth.middleware.ts # Authenticates the user from the token in the req object
| | | |____queryParamToToken.middleware.ts # Takes the token in the query param of the URL requested and puts in the req object
| | |____utils
| | | |____bodyStringToQuery.middleware.ts # Parses the body.paramString string into parameters for the query generator (found in req.parameters)
| | | |____prepareResponse.middleware.ts # Adds to the res object multiple parameteres (necessary if using the sendResponse.middleware)
| |____module
| | |____validator # Folder for the validators
| | |____util
| | | |____error.ts # A module that helps with error formatting
| | |____auth
| | | |____auth.module.ts # A module with a get request to the API service to identify the user
| | |____query # Folder for the query module config
| |____sequelize # Folder for the sequelize models
| | |____DB.ts # connection to the database
| |____router
| | |____api # Folder for the rouer
|____Constant
| |____Api.constant.ts # Constants that are automatically updated by the sync function for possible fetch/post/update/delete
|____toolbox
| |____url
| | |____customParamGenerator.ts # Converts a JSON object into it's query string for the query module
| |____factory # Factories that listen for the sendResponse.middleware
| | |____fetchById.factory.ts
| | |____post.factory.ts
| | |____delete.factory.ts
| | |____update.factory.ts
| | |____fetch.factory.ts
| | |____postFetch.factory.ts
|____Model # Moduls with typescript interfaces
| |____Express.ts
| |____Admin.ts
| |____Readme.md
| |____Worker.ts
|____src
| |____service # Folder for the services generated
| |____store # Store files
| | |____store.type.ts
| | |____reducer
| | |____action
| | |____type

Create model

This method creates the model files. One time use when creating the modules.

Notes You have to import the store and the router yourself for them to be effective.

Sync model

Takes the attributes from the sequelize Model and adds:

  • The sequelize Init call
  • The fields required in the validator
  • The properties in the interface used in the front end

License

MIT © Khaled Romdhane <khaled@medgo.fr>