@zeelo/corejs
v0.9.0
Published
Core JS files for every JS site.
Downloads
40
Readme
FE Core
Adapters and Transformers
NON inherited entities:
- The adapter implements both AdapterInterface and TransformerInterface.
- The AdapterInterface will be used to adapt self data.
- The TransformerInterface will be used to adapt data from the parent transformer if exists (when adapting mixed lists such as products list).
Inherited entities:
- The adapter implements only AdapterInterface and its responsibility is using the proper injected adapter.
- At the highest level we need only 1 transformer with the proper switch to call these adapters.
Use
- If the data we are trying to transform is from a basic entity (EventProduct, Stop, Perk, ...) we are using the adapter and either the adapt method or the transform method (preferring the transform one so we can avoid the new entity call).
- If the data we are trying to transform is from a parent entity (Product with type="event") we are using a factory with the EventProductAdapter injected. Inside the factory we will use a switch to determine which adapter we must use and then we will call the adapt method since this factory accepts only AdapterInterface.
Services
Every service will extend BaseEntityService since the logic is generic and reusable. Also we are typing the service with the proper entity to let the system (and the programmer) know what entity is being returned or used every time.
Clients
Every client will extend BaseEntityClient since the logic is generic and reusable. For clients we are only implementing the abstract method getBasepath() to let the system know where the endpoint starts.
Factories
The factories will be used to transform data from a mixed list or when the data comes from a parent entity and a type attribute (for example when retrieving data of an event product but the data is coming from a Products endpoint with the attribute type="product").
Scripts
Start
npm run start
ornpm start
: Installs everything and launches webpack in dev mode.npm run start:fresh
: Removes node_modules and public folder and then runsnpm start
. This is mainly used for when changing some dependencies.
Webpack
npm run webpack:dev
: Launches webpack in dev mode - watch and dev build. Use this one for dev mode when you don't need to install nor check dependencies.npm run webpack:prod
: Launches webpack in prod mode - production build.
Build
npm run build
: Removes node_modules and public folder and then runsnpm run webpack:prod
for a fresh build production.
Tests
npm test
ornpm run test
: Runs Jest testing.