2024.1.20 • Published 4 months ago

jari v2024.1.20

Weekly downloads
1
License
ISC
Repository
-
Last release
4 months ago

Jari

Jari is an opinionated code generation CLI library that makes it absolutely easy to build a CRUD RESTful Api with Node.js and Express.js using Typescript. Jari is capable of code generation for the following HTTP Verbs : POST, PUT and GET.

Tech Stack

  • MongoDb
  • Express.js
  • Typescript
  • Node.js

Installation

Use the package manager npm to install jari.

$ npm install jari -g

Usage

Creating a project

Creating the project where project-name is the name of the project

$ jari create 'project-name'

The following folder structure will be created

project-name
-- src/
------ root/
------ security/
------ utils/
------ app.ts
------ route.index.ts

CD into project directory

Generating API files

Creating blank api endpoints, api-name is the name of api

$ jari api 'api-name'

The following files will be created

api-name/
-- test/
------ create.spec.ts
------ edit.spec.ts
------ read.spec.ts
-- api-name.controller.ts
-- api-name.entity.ts
-- api-name.routes.ts
-- api-name.schema.ts
-- api-name.service.ts
-- api-name.utils.ts

Scaffolding API

Scaffolding api logic, this will create POST, PUT and GET methods inclusive of e2e tests and documentation

Step 1

$ jari schema 'api-name'

The name must be in singular, e.g. user not users

  • jari api user

For api that have more than one word. Use kebab-case or camel case

  • jari api user-detail
  • jari api userDetail

Step 2

You will be prompted to enter the number of fields the schema have

Lets generate user-detail schema. Enter the number of fields

Step 3

*********** FIELD 1 ***********

Enter Field 1 Name

Step 4

Select the field data type

Enter Field 1 Type
1. String
2. Boolean
3. Number
4. Schema.Types.ObjectId
5. Date
6. Enum

Step 5

Select if field is required/mandatory

Is Field 1 Required 
1. True
2. False

Step 6

Is Field 1 Unique 
1. True
2. False

NB: The above steps will be repeated for all fields

Managing Relationship/References

There are two types of relationships that are supported.

One-To-Many:

First create the child entity using steps above. Then create the parent entity/schema. In the parent schema, create a field that references the child schema. The field must have 4. Schema.Types.ObjectId data type. On prompt Enter Field 1 Reference enter the name of the child as entered on creation.

Many-To-Many:

Create both schemas, then create an additional one for relation which has two fields both referencing respective schemas

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

2022.4.5

4 months ago

2024.1.20

4 months ago

2022.5.3

2 years ago

2022.3.29

2 years ago

2022.4.0-1.6

2 years ago

2022.4.1

2 years ago

2022.3.31

2 years ago

2022.4.3

2 years ago

2022.4.4

2 years ago

2022.4.3-10

2 years ago

2020.11.1-8.1

3 years ago

1.0.10

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago