Ella API
Ella is a universal JavaScript application development framework.
Ella has two subprojects:
- Ella Framework is an opinionated Angular Universal implementation. As such, it includes UI code and a rendering server.
- Ella API is an opinionated Loopback API server.
Starting the Project
- install MySQL Server 5.7***
- During install, ensure you have created user test with pass test and DB Admin permission.
CREATE DATABASE test
- The ORM layer updates DB, but it must already exist.
- Optionally verify with
SHOW DATABASES
. - Probably you want to change DB name for production. Maybe
CREATE DATABASE ellacms
? - You can also verify your tables with
USE test
thenSHOW TABLES
npm install
npm start
- visit localhost:3000/explorer
*** Developed w 5.7.20x86, but may work with other versions. The application works out-of-the-box with MySQL, but with trivial modification the project will support other SQL DBs and even NoSQL DBs.
Additional Setup for Development
- Globally install Loopback 3 CLI:
npm install -g loopback-cli
Architecty Things
- The API server and the Angular Universal server are distinct. So there are three entry points in the code:
- API server entry point at /src/server.js
- Angular Universal server entry point at /src/main.ts
- Angular Universal UI entry point at /src/client/app.module.ts
Other Stuff
- conventions
- global webpack not recommended https://webpack.js.org/guides/installation/#global-installation
- main user model is called EllaUser because User is reserved by LoopBack itself
- entity property names are camelcase.
- DB stuff
- https://dev.mysql.com/downloads/windows/installer/5.7.html
- mysql-installer-web-community-5.7.20.0.msi
- localhost db server tcp/ip at port 3306, config type dev machine, test user pass: test
- test user, DB admin, host %, pass: test
- run as windows service, name MYSQL57
- X Protocol / doc store disabled
- C:\Program Files (x86)\MySQL\MySQL Server 5.7
- orchestration, ORM, API generation
- swagger
- Skin explorer
- TODO
- Seperate documentation repo which includes documentation for API and Framework side, in an extendable way so projects can include their own docs as well.
- CSV-to-object (array), then create many using https://stackoverflow.com/questions/45860853/how-to-insert-multiple-records-in-loopback
- Generate ERD and swagger file dynamically
- Remove authentication on a single endpoint: https://loopback.io/doc/en/lb2/Authentication-authorization-and-permissions.html#exposing-and-hiding-models-methods-and-endpoints
- /ella-api/server/models maps to /ella-framework/src/mock for test data
Hungarian Reference
- s: string
- o: object
- i: Number (long, int, double, etc)
- b: boolean
- p: Promise
- obs: Observable
- f: function
- v: variant
- m: module
- TitleCase: module or service
- ALLCAPS: constant, module, or service
- $: a DOM or DOM-like object, such as a jQuery or Angular object
- arr: an array
- el: a DOM object, specifically excluding it as not a DOM-like object.
- eg
$div = $('div'); elDiv = $div[0];
- eg
- _: locally scoped
- Generally only needed if there is some similarly-named, non-local variable.
- eg to distinguish sWord = function() { return _sWord; }
- Hungarian identifiers can be stacked, and precedence matters.
- For example, fpsWord(); should be a function which returns a promise resolving to a string.
- When and only when a hungarian identifier is variant, keep in mind the indicator may have two different meanings:
- vso is a variant which may be a string or an object
- vso is a variant which may be a string that represents an object (eg, it can be parsed with JSON.parse)
- Stacked hungarian remains in downcase. An upcase indicates the end of the Hungarian identifier.
- It's fpsWord(), not fPSWord()
- Arbitrary hungarian types can be indicated by downcasing.
- mycustomtype is fine, as long as it is a real custom type or class.
- Long names are not always needed, but sometimes they are.
- A long name is a hungarian identifier + arbitrary descriptive TitleCase naming
- A middle-sized name is a a hungarian identifier + arbitrary undescriptive and/or downcase letters
- Avoid middle-sized names. The hungarian indication is incorrect and the text isn't helpful.
- Short names are preferred when a method is so generic that contextual information doesn't exist. Like a utility.
- Short names suffice when there are no other variables of a given type in context.
- Short names do not suffice when multiple variables of the same type are in the same context.
- Examples:
- Short: o, s, i, obs
- Middle-sized: ob, obj, str, int, objold, objnw
- Long: oPreviousValue, oNewValue, sLetter, sWord, fsHtmlContent
- Respect third party conventions
- Hungarian is for your codebase, not for theirs (unless they use it)
- Use their syntax and conventional var names.
- Just make a comment referencing where their convention came from.
- For example, use
const fs = require('fs')