Build Nest.js common blocks and files insanely faster!
We use pre-built (.txt) templates and components to be copied from our library, get some modifications based on your answers to the CLI prompt, and finally pasted as (.ts) files into your project
We have 2 processes to complete the previously mentioned action, cloning and injection. The tool clones the (.txt) files and replaces the placeholders with the given processed answers before the're placed in the given location. Then it injects some blocks of code in different files so you don't need to modify ANYTHING.
You'll notice some comments in the generated files. We use those to locate the place in the code where the new blocks should be injected. Therefore, you can only remove them after you finish using the tool to build the blocks.
You might also notice some placeholder variables or values written in an uppercase format (e.g: FIELD_NAME
). TypeScript will notify you about them (since they're not defined). You can change those whenever you want since their purpose is just to let you know about the options without causing runtime errors.
-
Install nest-cli globally:
npm install -g @nestjs/cli
-
Install ravennest globally:
npm install -g @mustafa-alhasanat/raven-nest
-
Create a new project:
nest new project-name
cd project-name
-
Install the recommended dependencies and get the initial dev-kit:
ravennest init
Now you're ready to go!
-
Create the starting files:
ravennest create main
ravennest create --auth --format --aws --mailer app
ravennest create landing-page
ravennest create database
-
Create the special pre-built Users-table (recommended):
ravennest create --special user table
-
Create your first table:
ravennest create table
ravennest create column
Install the recommended dependencies in your project if they're not yet installed. These are different from the ones installed using nest new
command by default.
Usage:
ravennest init
"@nestjs/config"
"@nestjs/typeorm"
"@nestjs/platform-express"
"@nestjs/serve-static"
"@nestjs/swagger"
"class-validator"
"class-transformer"
"express-session"
"typeorm"
"mysql2 "
"pg"
"uuid"
"bcrypt"
"fs"
"@types/multer"
"@types/bcrypt"
"prettier"
Dockerize the application with the necessary modifications to the config files.
Usage:
ravennest dockerize
-
postgres-db: an image for initializing a PostgreSQL DB in the container.
-
nest-app: the main image that runs the application.
Create the necessary files and directories for the selected 'files-set'.
Usage:
ravennest create [options] <files-set>
Files Set | Description |
---|---|
main | Create the main files and enable Swagger page. |
database | Made the necessary changes for the database configuration. |
table | Create the necessary files for the table (module, controller, service, dto, entity). |
column | Perform the necessary file changes to add a new column to a table. |
relation | Perform the necessary file changes to establish a relation between two tables. |
Option | Files Set | Description | Details |
---|---|---|---|
aws | app | Add the AWS service to the app. | s3 bucket |
mailer | app | Add the mailer service to the app. | outlook, gmail |
special | table | Create a special type of tables. | product, notification |
Action | Command |
---|---|
create the main files | ravennest create --aws --mailer main |
configure the database | ravennest create database |
create a table | ravennest create table |
create a special type of tables | ravennest create --special product table |
create a column | ravennest create column |
create a relation | ravennest create relation |
- The main file is supposed to be located at the root
./main.ts
- The default used app directory is
./src/
- Inside the app directory, we have organized and grouped directories for each section:
- schemas
- dto
- enums
- entities
- decorators
- The naming convention for all generated files is as follow:
[name].[type].ts
- Examples:
app.module.ts
users.controller.ts
user-role.enum.ts
user.validator.ts
create-user.dto.ts
Currently, the tool only generate codes in TypeScript
Currently, the only available database is PostgreSQL
- MongoDB will be available to use
-
Open your terminal (steps for Ubuntu terminals)
-
Open the
.bashrc
file using either VSCode or the terminal itself:- either:
code ~/.bashrc
- or:
nano ~/.bashrc
- either:
-
Provide permission to run ravennest by adding the following line at the end of the file (after replacing the uppercase words with yours):
chmod +x /home/YOUR_USERNAME/.nvm/versions/node/YOUR_NODE_VERSION/bin/ravennest