Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
uranio-cli
Advanced tools
Uranio command line interface.
uranio-cli
is the only package you need in order to work with Uranio.
Uranio is a framework that builds CRUD APIs.
Uranio can be installed as one of the following repo:
core
, api
, trx
, adm
.
Each repo includes the previous one.
uranio-core
generates classes needed to interact with the database.
Uranio can interact with the following databases: MongoDB
More Database will be implemented in the future.
uranio-api
runs a web service that expose a CRUD API.
The web service use Express.js internally.
Uranio API can also be used inside a Lambda Function. It has a method that creates a service to use inside Netlify Functions.
uranio.api.lambda.create();
uranio-trx
creates Hooks that can be used to query the API from a client.
See Hooks
uranio-adm
creates a full Administration Panel that interact with the API.
Uranio CLI requires Node.js, version 14 or above.
To install uranio-cli
, run the following command from any directory
in your terminal:
yarn global add uranio-cli
or if you are using npm
npm install uranio-cli -g
When using the CLI in a CI environment we recommend installing it locally as a development dependency, instead of globally. To install locally, run the following command from the root directory of your project:
yarn add --dev uranio-cli
or if you are using npm
npm install --save-dev uranio-cli
Installing the CLI globally provides access to the uranio
command.
uranio [command]
Run help
for detailed information about CLI commands
uranio help
urn [command]
uranio init
This command initialize the repository. It will download and install all dependencies and copy all the files needed in order to start developing.
-s --root
(string) - Set project root.
If empty Uranio will auto detect the closest repo.-r --repo
(string) - Set Uranio repo [core, api, trx, adm]-f --force
(boolean) - Run without prompts.-p --pacman
(string) - Set package manager [npm, yarn]-k --docker
(boolean) - Compile and run inside a Docker container -
Docker must be installed on the machine.--docker_db
(boolean) - Run a DB in a Docker container -
Docker must be installed on the machine.--db
(string) - Set docker DB [mongo] -
Docker must be installed on the machine.uranio dev
This command starts a local development server.
Subcommand | description |
---|---|
dev:server | Run development only for server |
dev:panel | Run development only for the admin panel |
uranio build
This command build and compiled the code that will be needed in production.
Subcommand | description |
---|---|
build:server | Build the server |
build:panel | Build the admin panel |
uranio start
This command starts the server and the admin panel for production.
Subcommand | description |
---|---|
start:server | Start the server in production mode |
start:panel | Start the admin panel in production mode |
uranio deinit
This command deletes everything uranio created and return the repo in its initial state.
uranio info
This command prints the information uranio was initialized with.
uranio help
This command prints the list of all commands, parameters and options.
uranio version
#or
uranio
This command prints uranio-cli
version.
-v --verbose
(boolean) - log in verbose mode.-u --debug
(boolean) - log in debug mode.-n --hide
(boolean) - do not output log.-b --blank
(boolean) - log with no colors.-w --fullwidth
(boolean) - log in full width.-x --prefix
(string) - set a log prefix.-t --time
(boolean) - log with timestamp.-a --context
(boolean) - log with context.-l --filelog
(boolean) - save log on file.-i --spin
(boolean) - log with spinner.-e --native
(boolean) - log in native mode.-c --color_log
(string) - log color.-o --color_verbose
(string) - verbose log color.-q --color_debug
(string) - debug log color.Change directory to your npm repo:
cd /path/to/my/repo
If not already, run:
yarn init
#or
npm init
Then initialize Uranio with:
uranio init
The command will prompt with questions regarding the repository you want to initialize.
This might take a while, depending on your internet connection.
After it is done, your repo is ready for development.
In order to start developing you will need to create and run a development server. Run:
uranio dev
Here you will see all the logs, also it will print the IP of the Admin panel
in the case of the adm
repo.
Now you can start developing.
The first things that need to be defined in Uranio are Atom
s.
Atom
s are the objects stored in the database.
For example if we want to define an Atom
with the name product
, we need to
create the directory src/atoms/product
and the file src/atoms/prodcut/index.ts
.
The name product
will be picked from the name of the directory just created.
The src/atoms/product/index.ts
must export a default object with the Atom
definition, like so:
import uranio from 'uranio';
export default uranio.register.atom({
properties: {
title: {
type: uranio.types.PropertyType.TEXT,
label: 'Title'
},
price: {
type: uranio.tyoes.PropertyType.FLOAT,
label: 'Price'
},
// ...
},
// ...
});
Uranio already creates the following required Atoms
:
The parameter of the function uranio.register.atom
used in src/atoms/product/index.ts
is of type:
uranio.types.Book.Definition
.
properties: Book.Definition.Properties
plural?: string
authenticate?: boolean
connection?: ConnectionName
security?: Book.Definition.Security
dock?: Book.Definition.Dock
A full Atom
definition would be like this:
import uranio from 'uranio';
export default uranio.register.atom({
plural: 'customers',
authenticate: true,
security: {
type: uranio.types.BookSecurityType.UNIFORM,
_r: uranio.types.BookPermissionType.NOBODY
},
connection: 'main',
properties: {
full_name: {
type: uranio.types.PropertyType.TEXT,
label: 'Full name'
},
email: {
type: uranio.tyoes.PropertyType.EMAIL,
label: 'Email'
},
password: {
type: uranio.tyoes.PropertyType.ENCRYPTED,
label: 'Password',
hidden: true
},
groups: {
type: uranio.tyoes.PropertyType.ATOM,
label: 'Group',
atom: 'group',
optional: true
},
},
dock: {
url: '/products'
}
});
plural
define the plural word to define the Atom
.
e.g.: For the Atom
product
will be products
.
authenticate
define if the Atom
is an AuthAtom
.
See AuthAtom
AuthAtom
are Atom
s that can be authenticated, meaning they have
methods that authenticate with email
and password
.
For example they can be used to define customers.
Uranio already provide 2 AuthAtom
s: superuser
and user
.
connection
define with which connection the Atom
is stored.
connection
can be one of the follwing: main
(default), log
, trash
.
Uranio creates 3 database with 3 different connections.
main
connection is where are stored all the main Atom
s.log
connection is where are stored the Atom
s that define logs.trash
connection is where Uranio put the deleted Atom
s.Uranio API already provide 2
Atom
s that are used in thelog
connection. They arerequest
anderror
. For each API request anAtom
request
is stored. For each Uranio error andAtom
error
is stored.
security
define the security of the Atom
, meaning how the database can
be queried.
Uranio creates an Access Control Layer (ACL) before querying the database. This will check if the request can read or write in the database.
Each Atom
relation can have its own rules.
security
can be of type:
uranio.types.SecurityType.UNIFORM
.uranio.types.SecurityType.GRANULAR
.Default is UNIFORM
.
UNIFORM
permission will check on a relation level, meaning that the rule is
defined for the entire Atom
relation.
GRANULAR
permission will check on a Record level, meaning that the rules can
differ between the records. Each record has its own write and read rules.
Each relation / record has two attributes _r
and _w
, respectively for reading
and writing permission. The value of these attributes is an Atom
group
ID Array.
_r
will narrow from Everybody
_w
will widen from Nobody
_r
== nullish -> Everybody can read
_w
== nullish -> Nobody can write
For example:
// src/atoms/product/index.ts
import uranio from 'uranio';
export default uranio.register.atom({
// ...
security: {
type: uranio.types.BookSecurityType.UNIFORM,
_r: uranio.types.BookPermissionType.NOBODY
},
// ...
});
The above definition means that Nobody can read or write on the entire Atom
relation.
// src/atoms/product/index.ts
import uranio from 'uranio';
export default uranio.register.atom({
// ...
security: {
type: uranio.types.BookSecurityType.UNIFORM,
_w: uranio.types.BookPermissionType.PUBLIC
},
// ...
});
The above definition means that Everybody can read and write on the entire Atom
relation without
authenitcation.
// src/atoms/product/index.ts
import uranio from 'uranio';
export default uranio.register.atom({
// ...
security: {
type: uranio.types.BookSecurityType.UNIFORM,
_w: ['61d81a12f3e4ea6edbdcdd1e', '61d81a12f3e4ea6edbwcddff']
},
// ...
});
The above definition means that Everybody can read but only authenitcated AuthAtom
that have
groups with the following ids: ['61d81a12f3e4ea6edbdcdd1e', '61d81a12f3e4ea6edbwcddff']
can write.
// src/atoms/product/index.ts
import uranio from 'uranio';
export default uranio.register.atom({
// ...
security: {
type: uranio.types.BookSecurityType.GRANULAR,
},
// ...
});
When the security
type is GRANULAR
, the ACL will check if the singles Atom
s
have the right permission to be read or written.
If dock
property is defined, Uranio will create the CRUD API and expose it
in the web serivce.
dock
must have a url
property starting with /
.
For example:
// src/atoms/product/index.ts
import uranio from 'uranio';
export default uranio.register.atom({
// ...
dock: {
url: '/products'
},
// ...
});
will create a route in the webserice https://[WEBSERVICEURL]/uranio/api/products
where
the Atom
relation product
can be queried.
[WEBSERVICEURL]
can be defined in uranio.toml
.
/uranio/api
prefix can be defined in uranio.toml
.
See uranio.toml definition
dock
has also the properties auth_url
that need to be defined when
authenticate
is equal to true
.
auth_url
define the route url where the AuthAtom
can authenticate.
For example:
// src/atoms/customer/index.ts
import uranio from 'uranio';
export default uranio.register.atom({
// ...
dock: {
url: '/customers',
auth_url: '/auth-customer'
},
// ...
});
will create a route in the webservice https://[WEBSERVICEURL]/uranio/api/auth-customer
tha will accept as body in JSON format:
{
email: 'uranio@email.com',
password: 'MyPassword1234'
}
and will return an AuthResponse
object with a token and a http-only cookie
if authenitcated.
Type Book.Definition.Properties
is a list of all the relation key.
Each key is of type Book.Definition.Property
:
//type Book.Definition.Property
Property.ID |
Property.Text |
Property.LongText |
Property.Email |
Property.Integer |
Property.Float |
Property.Binary |
Property.Encrypted |
Property.Day |
Property.Time |
Property.SetString |
Property.SetNumber |
Property.EnumString |
Property.EnumNumber |
Property.Atom |
Property.AtomArray;
Each property type has the following common properties:
type: BookPropertyType
label: string
optional?: boolean
hidden?: boolean
unique?: boolean
default?: any
on_error?: (old_value: any) => any
BookPropertyType
can be one of the following
// BookPropertyType
ID = 'ID',
TEXT = 'TEXT',
LONG_TEXT = 'LONG_TEXT',
EMAIL = 'EMAIL',
INTEGER = 'INTEGER',
FLOAT = 'FLOAT',
BINARY = 'BINARY',
ENCRYPTED = 'ENCRYPTED',
DAY = 'DAY',
TIME = 'TIME',
ENUM_STRING = 'ENUM_STRING',
ENUM_NUMBER = 'ENUM_NUMBER',
SET_STRING = 'SET_STRING',
SET_NUMBER = 'SET_NUMBER',
ATOM = 'ATOM',
ATOM_ARRAY = 'ATOM_ARRAY'
FAQs
Uranio command line interface [DEPRECATED]
We found that uranio-cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.