---
# System prepended metadata

title: Template API

---

# Template API

###### tags: API

## Technologies
* nodejs
* nestjs framework (https://nestjs.com/)
* embeded javascript templating Library (https://handlebarsjs.com/)
* embeded java reporting library (https://community.jaspersoft.com/)
* mongodb

## Enums
```typescript=
enum RecordState {
    DRAFT,
    ACTIVE,
    INACTIVE,
}

enum TemplateType {
    HANDLEBARS,
    JASPER,
}

enum Env {
    UNCATEGORIZED,
    MAIN,
    STAGING,
    TRAINING,
    TESTING,
}
```

## Schemas
```typescript=
@Schema({ collection: 'templates' })
class TemplateSchema {
    @Prop({ required: true, enum: TemplateType, default: TemplateType.HANDLEBARS })
    public type: TemplateType;

    // main, staging, training, testing
    @Prop({ required: true, enum: Env, default: Env.MAN })
    public env: Env;

    // Unique Keyword of app
    @Prop({ required: true })
    public appKeyword: string;

    // Template Unique Name - Keyword
    @Prop({ required: true, unique: true })
    public keyword: string;

    // Human Friendly Name
    @Prop({ required: false })
    public name: string;
    
    @Prop({ required: false })
    public description: string;
    
    @Prop({ required: true, type: Template })
    public template: Template;

    @Prop({ required: true })
    public modelExample: string;

    @Prop({ required: true, type: Record })
    public record: Record;
}

export class Template {
    @Prop({ required: false })
    public handlebars: string;

    @Prop({ required: false, type: Jasper })
    public jasper: Jasper;
}

export class Jasper {
    @Prop({ required: false, type: File })
    public jrxml: File;

    @Prop({ required: false, type: File })
    public compiled: File;
}

export class Record {
    @Prop({ required: true, enum: RecordState, default: RecordState.DRAFT })
    public state: RecordState;

    @Prop({ required: true, type: Date })
    public createdAt: Date;

    @Prop({ required: false, type: Date })
    public updatedAt: Date;

    @Prop({ required: true, type: Boolean, default: false })
    public deleted: boolean;
}
```



SET email-tx:1111 "1111"
EXPIRE email-tx:1111 1
keys email-tx:*