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

ember-mirage-gen

v0.0.4

Published

The default blueprint for ember-cli addons.

Downloads

3

Readme

ember-mirage-gen

The addon will give the complete Mirage section after receiving the API call.

Demo

Demo is available here mirage-gen-common

Installation

ember install ember-mirage-gen

Compatibility

  • Ember.js v2.18 or above
  • Ember CLI v2.13 or above

Documentation

Consider we have the following sample response for the particular request

  request = 'https://sample/studentdata';
  response = {
            student: {
                'personal-data': {
                  name: 'myname',
                  age: 12
                },
                'educational-data': {
                   marks: 98,
                   section: 'B'
                }
             } 
            }

The output for this response as mirage-gen-option

As shown in the above image, we have the section of the object tree. Here, we can select the type of the node. The types are

  1. Fixture
  2. Factory
  3. Normal

After selecting the option, we should click the Generate Info button.

Note: if the node is normal, then it will be included in the config file section

mirage-gen-api

Info strucure

Here, we have three sections

  1. config file
  2. DataBase
  3. Test file

1) config file:

This file has the API endpoints.

   this.get('your request', function(schema, request) {
      return your response;
   })

2) DataBase

This section contains a list of fixtures and factories which are chosen in the previous section. Here, we can also compare our result with the available factory/fixture and generate the new results. For more info try it in the demo page.

3) Test file

It has the creation list of factories as well as fixtures like in the Ember test file.

Comparison

Sometimes we are not able to parse the object for comparison.

Example:

 import { Factory, faker } from 'ember-cli-mirage';

 let myFactory = Factory.extend({
   id() {
     return faker.random.number();
   },
   myNumber() {
     return faker.random.number();
   }
 });

  export default myFactory;

For good parsing kindly add the code as below

import { Factory, faker } from 'ember-cli-mirage';

let myFactory = Factory.extend(
  // $MirageSection-Start$
  {
    id() {
      return faker.random.number();
    },
    myNumber() {
      return faker.random.number();
    }
  }
  // $MirageSection-End$
);

export default myFactory;

Usage

  1. Add the following code in the application.hbs
  <MirageGen @top="value" @left="value" />
  1. In your config/environment.js, add an ember-mirage-gen object as below.
// config/environment.js
let ENV = {
  'ember-mirage-gen': {
    isEnabled: environment === 'development', // Mandatory
    isOnlyForCurrentDomain: true, // optional
    excludedNodes: [] // optional
  }
};
  • isEnabled - it works only when this node is true

  • isOnlyForCurrentDomain - Allow only the same domain API's.

  • excludedNodes - sometimes we got the same node for all responses and we don't need the mirage information for those nodes. So, we can exclude those nodes by adding those nodes in this array. example: page-info conatins page information

  1. Visit the app and click the mirage-gen icon, you will see the list of API's

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.