Gathering detailed insights and metrics for @noveo/scaffolding
Gathering detailed insights and metrics for @noveo/scaffolding
Gathering detailed insights and metrics for @noveo/scaffolding
Gathering detailed insights and metrics for @noveo/scaffolding
npm install @noveo/scaffolding
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
The package is designed to quickly create a Node.js application avoiding writing a lot of boring boilerplate code. Finally it could provide an http server based on express and @noveo/swagger-middleware. The server is considered to be an REST API providing CRUD methods for several entities and supporting authentication for methods. Finally it will be similar to boilerplate application
Although it also lets to create React based frontend application. You need to use generator-ui which is described below.
The package is designed as cli tool based on yeoman-environment You might get to be familiar with yeoman and yeoman-environment documentation. It is not necessary, but you'd better to understand what 'generator' is.
Often it DOESN'T NEED TO BE INSTALLED.
For example you don't need to install it for creating application
from scratch. You can just run it with npx
. See the chapter
Running.
Some generators could be run in an existing application root folder. In such case it could be convenient to have the package installed in the application. You can install it from npm registry
npm i @noveo/scaffolding
Sometimes it could be useful to install it from git repo.
npm i git+ssh://git@gitlab.noveogroup.com:devteam/back/scaffolding.git#develop
Here you can read more about installing packages from git repo.
Actually you don't need to add it as a project dependency,
especially as production dependency. Just run generators and forget them.
Even you have decided to include it into dependency list than
add it into development dependencies using --save-dev
.
We DO NOT RECOMMEND to install it GLOBALLY.
If you just want to create a new Node.js application than you can just run (in case you have installed the package in the current directory)
npx scaffolding
It runs default generator generator-app which combines several generators. It asks you several questions and then creates the application. generator-app documentation paragraph describes questions. It can help you to understand how to build an application as you want.
When you want to run it without installation you can do it in a such way
npx @noveo/scaffolding
or
npx git+ssh://git@gitlab.noveogroup.com:devteam/back/scaffolding.git#develop
Then you can run any generator described in Generators
npx scaffolding [<generator-name> [<generator-arguments>]]
Set generator name to call it. By default generator-app is called. Then you can set generator arguments
It creates a basic application structure and calls other generators to advance application.
npx scaffolding app
It requires application name, stores and uses further.
It requires application folder name which could be a name of the folder into the current directory, relative path to the folder from the current directory, absolute path to the folder.
If you specify an existing folder, the generator wil ask for confirmation
Create in none empty folder?
. If you decline, the generator will stop
without creating any files.
It is RECOMMENDED to run generator on non-existent folder.
If you confirm, the generator will call another generator generator-git at the end of the current generator chain. See below for more information about generator-git.
If you confirm, the generator will call another generator generator-security. See below for more information about generator-security.
If you confirm, the generator will call another generator generator-database. See below for more information about generator-database.
If you confirm, the generator will call another generator generator-users. See below for more information about generator-users.
If you confirm, the generator will call another generator generator-ui. See below for more information about generator-ui.
The application is supposed to be a Node.js REST API http server.
Created files are package.json, .gitignore, .npmrc, .eslintrc, app.js Then config and application folders are created. app.js file just runs server defined in application folder.
Config folder is supposed to store application configuration in terms of node-config package. This package is user in application for configuration management. You may see standalone.js file in config folder. It is a definition for application with NODE_ENV=standalone. Ask Andrey Dergaev why there is 'standalone' env instead of usual 'development'.
Application folder contains all the application stuff. There is a definition
of http server based on express and
@noveo/swagger-middleware.
Then there is a basic definition of REST API in terms of swagger.
Then there is an essences folder which is considered to store
source codes for API entities. Basically there is only one entity defined
called 'ping' with only one method. Then there are some libraries.
With all additional generators called finally the application
is similar to boilerplate
It just runs git init
command silently and then commits all
files as Initial commit
.
npx scaffolding git
We have already mention @noveo/swagger-middleware It has a mechanism for authentication management. There are some poor documentation here and here Then you can try to figure it out with an usage example or boilerplate repo
npx scaffolding sequrity
It requires to choose which types of authentication you want to add into project. Briefly Basic auth is supposed to use some login and password. It looks more like authorization stuff. Api key is supposed to use some Access Token or Authorization header.
If you chose Api key on previous question, It requires to set a name of a request header which will be used as api key.
Finally it adds security definitions into ./application/api.yml Then it adds securityCollection items initialization into ./application/index.js Then it adds secure middleware into server initialization into ./application/index.js securityCollection items requires callback implementation afterwards. They could be implemented by you or defined by generator-users after.
Usually you need to add apiKey auth for all methods excluding several like login and logout (they do not require authentication, usually they have their own security definition overriding common) Sometimes you need to add basic auth for several or all methods. And it seems pointless to turn on both auth for all methods, but you have such possibility with the generator.
When you added one or both auth with the generator you have auths being turned on global level in api.yml (it means they are turned on for all methods of api). You may remove it from api.yml and add it into security definition of any method to make it responsible not for all methods but for several.
It creates some stuff to initialize database connection and Sequelize instance. It supports PostrgeSQL and SQLite now. Also it provides compatibility to use sequelize-cli.
npx scaffolding database
It requires to choose what kind of database you want to use.
It requires to configure the database connection host for PostgreSQL. The host is appended into default config.
It requires to configure the database connection port for PostgreSQL. The port is appended into default config.
It requires to configure the database connection name for PostgreSQL. The database name is appended into default config.
It requires to configure the database connection username for PostgreSQL. The database username is appended into default config.
It requires to configure the database connection password for PostgreSQL. The database password is appended into default config.
It requires to configure the database file path for SQLite. The database file path is appended into default config.
It adds database configuration into default config.
It creates folder application/libs/postgres or application/libs/sqlite. The folder contains initialization of Sequelize instance based on database config. Also the folder contains sequelize-config-proxy.js file that provides config transformation from project's format to sequelize (and sequelize-cli) compatible format.
Then it creates .sequelizerc. This file is required for sequelize-cli correct config access.
Then it creates ./docker/postgres-docker-compose.yml file for PostgreSQL. So you have convenient way to start database quickly.
Then it adds "migrate" script into package.json file.
Finally it adds database connection initialization into ./application/index.js
Current generator implementation will fail on trying to run it without generator-database being run before. It relies on database stuff.
The generator is designed to create CRUD methods for user entity and login/logout methods based on user models and token model.
npx scaffolding users
It requires you to choose what kinds of stuff it is necessary to create.
list+CRUD means that definitions and controllers for methods of getting list of users, getting user by id, creating user, updating user, deleting user will be created.
authentication API means that definitions and controllers for methods creating user access token (login) and removing user access token (logout) will be created.
You have to confirm because current implementation cannot work without database stuff generated by generator-database
It creates React application for managing data using REST API.
npx scaffolding ui
It creates ui folder which contains frontend application. Application contains builtin Login form which is considered to be composed with backend application generated by previously described generators. It uses login method, user and token entities. Also it component for representing user entity and providing crud operations on the entity.
Generator creates model definition and migration both in terms of sequelize. Generation is based on json-schema of model entity. It is supposed to create models for new entities in ./application/essences but generator for creating new entities is not ready yet.
It is required to run this generator into the project root which was generated using generator-database. It check database stuff before run.
Then it REQUIRES model description in json-schema format.
Then you can run it like this
npx scaffolding db-model
Choose JSON Schema. SQL does not work for now.
Provide path to the file with json-schema of the entity
Provide name for the model
Provide table name for the model. This name is used as table name in database.
Check properties which are required for the entity. They are set required in validation schemas. The they are set NOT NULL into database.
Choose which property is supposed to be a primary key in database. The property is considered to have flag "primaryKey: true" into model definition (but it seems to be not working)
Provide the path where the model is set to be placed. The best place is directory of appropriate entity in ./application/essences
It is a generator for creating entity directories into ./application/essences with prepared controllers, validation schemas of CRUD operations.
This generator call generator-db-model. That's why it has the same restrictions:
It is required to run this generator into the project root which was generated using generator-database. It check database stuff before run.
Then it REQUIRES model description in json-schema format.
Then you can run it like this
npx scaffolding essention
It is required to put the name of the essence or entity which stuff would be created
It is required to put the path to the json-schema description of the entity. The json-schema would be used for creation valiation schemas of crud methods. Then the schema would be used for generator-db-model purposes.
It is required to provide the path where the entity folder would be created.
Usually it is ./application/essences
. If ./application/essences
exists
it would be suggested as default.
It is required to confirm db-model creation or not. Confirmation will call generator-db-model with some preanswered questions.
You need to choose which methods it is required to add into api definition
definition
subdirectory with
references on model json schema definitionIt is a generator for creating entity form providing CRUD operations.
It is NOT WORKING now. It is on development.
There was an old documentation how to add new generators. It looks non-relevant.
No vulnerabilities found.
No security vulnerabilities found.