Thanks to NodeJS module generator/boilerplate.
- Babel - Write next generation JavaScript today;
- Jest - JavaScript testing framework used by Facebook;
- ESLint - Make sure you are writing a quality code;
- Prettier - Enforces a consistent style by parsing your code and re-printing it;
- Flow - A static type checker for JavaScript used heavily within Facebook;
- Travis CI - Automate tests and linting for every push or pull request;
- Documentation - A documentation system so good, you'll actually write documentation.
The easiest way to use nod is through the npm
.
$ npm install datran-es6 --save # or yarn add datran-es6
$ npm test # run tests with Jest
$ npm run coverage # run tests with coverage and open it on browser
$ npm run lint # lint code
$ npm run docs # generate docs
$ npm run build # generate docs and transpile code
$ npm run watch # watch code changes and run scripts automatically
$ npm run patch # bump patch version and publish to npm e.g. 0.0.1
$ npm run minor # bump minor version and publish to npm e.g. 0.1.0
$ npm run major # bump major version and publish to npm e.g. 1.0.0
- Test method: Switch from
jest
tomocha
, fixed async/await to run test in mocha.
- serializer
- parser
- scope
- serialize
- create
- item
- collection
- Parser
- constructor
- createScope
- isRoot
- isIncluded
- isExcluded
- getPath
- getIdentifier
- toPath
- serializer
- item
- collection
- hasIncludes
- create
Output serializer & composer
Field parser
Root scope
Parameters
data
anyscope
any {identifier, resource}scope.identifier
scope.resource
This function says hello.
Parameters
name
Some name to say hello for.
Returns any The hello.
Parameters
resourceType
options
any Optional parameters- exlcudes: Exclude string (eg req.query.exclude)- includes: Include string (eg req.query.include)
- serializer
- parser (optional, default
{}
)
resource
any instance of the resource type (Collection|Item)
Creates an item resource
Parameters
model
anytransformer
any
Creates a collection resource
Parameters
model
anytransformer
any
Fields parser
Format
- post,post.comments,post.author
- post:limit(5):order(created_at|desc),-post.comments
- post,-votes
Parameters
fields
Character used to separate parameters
Included fields
Fields to exclude
Included fields paramters
Parses includes and exclude fields
Returns Parser
Constructor
Parameters
options
Object includes: Requested includes (optional, default{}
)
Creates a child scope that is nested from current scope
Parameters
identifier
String Child scope identifierresource
any Instance of resource type
Returns Scope
Checks if this scope is the root scope
Returns Boolean
Checks if an identifier is included from current scope
Parameters
identifier
any
Checks if an identifier is excluded from current scope
Parameters
identifier
any
Gets the scope identifier path
Returns String
Get scope (include) identifier
Returns any scope identifier
Parameters
includeIdentifier
any
Default Serializer
Serializes a collection
Parameters
key
anydata
any
Serializes a resource item
Parameters
key
anydata
any
Serialize an empty resource
Returns Object
Embeds the includes data to the transformed data
Parameters
data
anyincludeData
any
Helper for creating an Item resource
Parameters
model
anytransformer
any
Helper for creating a Collection resource
Parameters
model
anytransformer
any
Checks if the transformer has any includes defined
Returns Boolean
Creates a new transformer blueprint using object pattern
const MyTransformer = Transformer.create({
transform () {}
})
Parameters
proto
any
MIT © Diego Haz