@astro-my/template-fetcher

Template Fetcher and Parser from s3

Stats

StarsIssuesVersionUpdatedCreatedSize
@astro-my/template-fetcher
2.0.13 years ago3 years agoMinified + gzip package size for @astro-my/template-fetcher in KB

Readme

Astro Template Fetcher

This is a standalone npm package to fetch the template from s3 depending upon the parameters provided.

Steps to use

  1. Include this package in startup boot or app.js and invoke build method, passing configuration:
  • region (required)

  • folderName (required)

  • accessKeyId (optional)

  • secretAccessKey (optional)

  1. Where ever you need to get the template, please use these methods,
  • raw(params) : if you need to fetch the raw template without any modification or data injection

  • interpolate(params, data) : if you need to inject the data into template, pass it in this function

    params: stores the information related to the template which needs to be fetched

    • entity: what entity a template belongs to, eg: partner
    • entityId: the unique identifier of entity, eg: partnerCode/partnerId of partner
    • category: what kind of template you want, email, sms or any other
    • type: what kind of template, registration, verification or any other
    • language: template language

    data: contains the information which needs to be replaced

    Example:

    const TemplateFetcher = require('@astro-my/template-fetcher');
    
    TemplateFetcher.build({
      region: process.env.region,
      accessKeyId: process.env.accessKeyId,
      secretAccessKey: process.env.secretAccessKey
    });
    
    // to fetch raw template
    const template = await TemplateFetcher.raw({
      entity: 'partner',
      entityId: 'partnerCode',
      language: 'fr',
      category: 'email',
      type: 'verification'
    });
    
    // to fetch interpolated template
    const template = await TemplateFetcher.interpolate({
      entity: 'partner',
      entityId: 'partnerCode',
      language: 'fr',
      category: 'email',
      type: 'verification'
    }, {
        username: 'rahul'
      });
    

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.