Hamta Libraries
Installation
npm i @adonisjs/i18n node ace configure @adonisjs/i18n npm i @hamta/adonis node ace configure @hamta/adonis
Model Signature Use:
import {withSignature,RowSignature} from '@ioc:Hamta/Lucid/Signature' @withSignature({column: 'signature', salt: '6ba7b810-9dad-11d1-80b4-00c04fd430c8', enable: true, [fields]:[]}) export default class Transfer extends compose(BaseModel,RowSignature) { }
withSignature params
- column : signature field name in database
- salt : custom string for create hash code
- enable : enable create ans save signature this table
- fields : list of fields for create signature
check row isValidSignature
const user=await User.findOrFail() user.isOk() // return true or false
Filter Components Use:
const accounts = await User.query() .where('userId', userId) .whereFilterPaginate(request)
Hamta Check Develope Mode Helper:
change config in config/hamta.ts
import {Developer} from '@ioc:Hamta/Helper' if(Developer.isDeveloper(127.0.0.1)){ }
Hamta Command Run Developer:
change config in config/hamta.ts
import Runner from '@ioc:Hamta/Test' const command=await Runner.execute('queue:listen', ['queue=TtsQueue'], true) ... command.kill()
OR
import Runner from '@ioc:Hamta/Test' const command=await Runner.execute('queue:listen', ['queue=TtsQueue']) ...
Use I18n Middleware:
after install i18n package and install @hamta/adonis
start/kernel.ts
Server.middleware.register([....,() => import('App/Middleware/DetectUserLocale')])
use:
public messages: CustomMessages = { 'username.required': Application.i18n.formatMessage('validator.required', { attribute: Application.i18n.formatMessage('translate.attributes.username'), }), 'username.emailORmobile': Application.i18n.formatMessage('validator.the_mobile_number_email_format_is_wrong'), }
more information