@hed-hog/core 0.0.95 → 0.0.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { DeleteDTO } from '@hed-hog/api';
2
+ import { Response } from 'express';
2
3
  import { CreateDTO } from './dto/create.dto';
3
4
  import { TestMailDTO } from './dto/test-mail.dto';
4
5
  import { UpdateDTO } from './dto/update.dto';
@@ -32,6 +33,7 @@ export declare class MailController {
32
33
  created_at: Date;
33
34
  updated_at: Date;
34
35
  }>;
36
+ getHtml(id: number, res: Response, queryLocale?: string, decoratorLocale?: string): Promise<void>;
35
37
  create(data: CreateDTO): Promise<{
36
38
  mail_locale: {
37
39
  body: string;
@@ -1 +1 @@
1
- {"version":3,"file":"mail.controller.d.ts","sourceRoot":"","sources":["../../src/mail/mail.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAQ,MAAM,cAAc,CAAC;AAgB/C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAEa,cAAc;IAGvB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAIrC,IAAI,CAAW,MAAM,KAAA,EAAgB,gBAAgB,KAAA;;;;;;;;;IAKrD,GAAG,CACoB,EAAE,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,MAAM,EAC3B,eAAe,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;IAO9B,MAAM,CAAS,IAAI,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;IAK9B,YAAY;;;;IAKZ,MAAM,CAA4B,EAAE,EAAE,MAAM,EAAU,IAAI,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;IAQrE,MAAM,CAAS,IAAI,EAAE,SAAS;;;IAK9B,YAAY,CAAW,MAAM,EAAE,MAAM,EAAU,IAAI,EAAE,WAAW;CAGvE"}
1
+ {"version":3,"file":"mail.controller.d.ts","sourceRoot":"","sources":["../../src/mail/mail.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAQ,MAAM,cAAc,CAAC;AAkB/C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAEa,cAAc;IAGvB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAIrC,IAAI,CAAW,MAAM,KAAA,EAAgB,gBAAgB,KAAA;;;;;;;;;IAKrD,GAAG,CACoB,EAAE,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,MAAM,EAC3B,eAAe,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;IAQ9B,OAAO,CACgB,EAAE,EAAE,MAAM,EAC9B,GAAG,EAAE,QAAQ,EACH,WAAW,CAAC,EAAE,MAAM,EAC3B,eAAe,CAAC,EAAE,MAAM;IAuC9B,MAAM,CAAS,IAAI,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;IAK9B,YAAY;;;;IAKZ,MAAM,CAA4B,EAAE,EAAE,MAAM,EAAU,IAAI,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;IAQrE,MAAM,CAAS,IAAI,EAAE,SAAS;;;IAK9B,YAAY,CAAW,MAAM,EAAE,MAAM,EAAU,IAAI,EAAE,WAAW;CAGvE"}
@@ -32,6 +32,40 @@ let MailController = class MailController {
32
32
  const locale = queryLocale || decoratorLocale;
33
33
  return this.mailService.get(locale, id);
34
34
  }
35
+ async getHtml(id, res, queryLocale, decoratorLocale) {
36
+ const locale = queryLocale || decoratorLocale;
37
+ const mail = await this.mailService.get(locale, id);
38
+ const html = `<!DOCTYPE html>
39
+ <html>
40
+ <head>
41
+ <meta charset="UTF-8">
42
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
43
+ <title>${mail.subject}</title>
44
+ <style>
45
+ body {
46
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
47
+ line-height: 1.6;
48
+ color: #333;
49
+ max-width: 600px;
50
+ margin: 0 auto;
51
+ padding: 20px;
52
+ }
53
+ a {
54
+ color: #0066cc;
55
+ text-decoration: none;
56
+ }
57
+ a:hover {
58
+ text-decoration: underline;
59
+ }
60
+ </style>
61
+ </head>
62
+ <body>
63
+ ${mail.body}
64
+ </body>
65
+ </html>`;
66
+ res.setHeader('Content-Disposition', `attachment; filename="${mail.slug}-${locale}.html"`);
67
+ res.send(html);
68
+ }
35
69
  async create(data) {
36
70
  return this.mailService.create(data);
37
71
  }
@@ -69,6 +103,17 @@ __decorate([
69
103
  __metadata("design:paramtypes", [Number, String, String]),
70
104
  __metadata("design:returntype", Promise)
71
105
  ], MailController.prototype, "get", null);
106
+ __decorate([
107
+ (0, common_1.Get)(':id/html'),
108
+ (0, common_1.Header)('Content-Type', 'text/html'),
109
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
110
+ __param(1, (0, common_1.Res)()),
111
+ __param(2, (0, common_1.Query)('locale')),
112
+ __param(3, (0, api_locale_1.Locale)()),
113
+ __metadata("design:type", Function),
114
+ __metadata("design:paramtypes", [Number, Object, String, String]),
115
+ __metadata("design:returntype", Promise)
116
+ ], MailController.prototype, "getHtml", null);
72
117
  __decorate([
73
118
  (0, common_1.Post)(),
74
119
  __param(0, (0, common_1.Body)()),
@@ -1 +1 @@
1
- {"version":3,"file":"mail.controller.js","sourceRoot":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;;kDAGd;AAGK;IADL,IAAA,cAAK,EAAC,KAAK,CAAC;IACC,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;IAAc,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAO,sBAAS;;4CAK1E;AAGK;IADL,IAAA,eAAM,GAAE;IACK,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAO,eAAS;;4CAEnC;AAGK;IADL,IAAA,aAAI,EAAC,MAAM,CAAC;IACO,WAAA,IAAA,mBAAM,GAAE,CAAA;IAAkB,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAO,2BAAW;;kDAErE;yBA3FU,cAAc;IAF1B,IAAA,UAAI,GAAE;IACN,IAAA,mBAAU,EAAC,MAAM,CAAC;IAGd,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAW,CAAC,CAAC,CAAA;qCACR,0BAAW;GAHhC,cAAc,CA4F1B"}
@@ -802,6 +802,12 @@
802
802
  role:
803
803
  - where:
804
804
  slug: admin
805
+ - url: /mail/:id/html
806
+ method: GET
807
+ relations:
808
+ role:
809
+ - where:
810
+ slug: admin
805
811
  - url: /mail
806
812
  method: POST
807
813
  relations:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hed-hog/core",
3
- "version": "0.0.95",
3
+ "version": "0.0.96",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
@@ -33,8 +33,8 @@
33
33
  "@hed-hog/api-pagination": "0.0.4",
34
34
  "@hed-hog/api": "0.0.3",
35
35
  "@hed-hog/api-prisma": "0.0.4",
36
- "@hed-hog/api-locale": "0.0.10",
37
- "@hed-hog/api-mail": "0.0.7"
36
+ "@hed-hog/api-mail": "0.0.7",
37
+ "@hed-hog/api-locale": "0.0.10"
38
38
  },
39
39
  "exports": {
40
40
  ".": {
@@ -6,14 +6,17 @@ import {
6
6
  Controller,
7
7
  Delete,
8
8
  Get,
9
+ Header,
9
10
  Inject,
10
11
  Param,
11
12
  ParseIntPipe,
12
13
  Patch,
13
14
  Post,
14
15
  Query,
16
+ Res,
15
17
  forwardRef,
16
18
  } from '@nestjs/common';
19
+ import { Response } from 'express';
17
20
  import { CreateDTO } from './dto/create.dto';
18
21
  import { TestMailDTO } from './dto/test-mail.dto';
19
22
  import { UpdateDTO } from './dto/update.dto';
@@ -42,6 +45,50 @@ export class MailController {
42
45
  return this.mailService.get(locale, id);
43
46
  }
44
47
 
48
+ @Get(':id/html')
49
+ @Header('Content-Type', 'text/html')
50
+ async getHtml(
51
+ @Param('id', ParseIntPipe) id: number,
52
+ @Res() res: Response,
53
+ @Query('locale') queryLocale?: string,
54
+ @Locale() decoratorLocale?: string,
55
+ ) {
56
+ const locale = queryLocale || decoratorLocale;
57
+ const mail = await this.mailService.get(locale, id);
58
+
59
+ const html = `<!DOCTYPE html>
60
+ <html>
61
+ <head>
62
+ <meta charset="UTF-8">
63
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
64
+ <title>${mail.subject}</title>
65
+ <style>
66
+ body {
67
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
68
+ line-height: 1.6;
69
+ color: #333;
70
+ max-width: 600px;
71
+ margin: 0 auto;
72
+ padding: 20px;
73
+ }
74
+ a {
75
+ color: #0066cc;
76
+ text-decoration: none;
77
+ }
78
+ a:hover {
79
+ text-decoration: underline;
80
+ }
81
+ </style>
82
+ </head>
83
+ <body>
84
+ ${mail.body}
85
+ </body>
86
+ </html>`;
87
+
88
+ res.setHeader('Content-Disposition', `attachment; filename="${mail.slug}-${locale}.html"`);
89
+ res.send(html);
90
+ }
91
+
45
92
  @Post()
46
93
  async create(@Body() data: CreateDTO) {
47
94
  return this.mailService.create(data);