nestjs-mailchannels 0.0.0-stage → 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MailChannels
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,204 @@
1
- # Temporary Holding Version
1
+ # Nestjs MailChannels
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <!-- oxfmt-ignore-start -->
4
+ [![npm version][npm-version-src]][npm-version-href]
5
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
6
+ [![License][license-src]][license-href]
7
+ <!-- oxfmt-ignore-end -->
8
+
9
+ MailChannels Email API module integration for NestJS.
10
+
11
+ Leverages [`@mailchannels/sdk`](https://github.com/mailchannels/mailchannels-email-api-sdk-js)
12
+ package, the Official MailChannels Email API SDK for Node.js.
13
+
14
+ - [✨ Release Notes](CHANGELOG.md)
15
+ - [🏀 Online playground](https://stackblitz.com/github/yizack/nestjs-mailchannels?file=playground%2Fsrc%2Fapp.module.ts)
16
+
17
+ ## Contents
18
+
19
+ - [Features](#features)
20
+ - [Requirements](#requirements)
21
+ - [Installation](#installation)
22
+ - [Usage](#usage)
23
+ - [License](#license)
24
+ - [Development](#development)
25
+
26
+ ## Features
27
+
28
+ - All MailChannels Email API SDK features available
29
+
30
+ ## Requirements
31
+
32
+ - NestJS 12 or higher
33
+ - MailChannels account and Email API key
34
+
35
+ ## Installation
36
+
37
+ 1. Add `nestjs-mailchannels` dependency to your project
38
+
39
+ ```sh
40
+ # npm
41
+ $ npm install nestjs-mailchannels
42
+
43
+ # yarn
44
+ $ yarn add nestjs-mailchannels
45
+
46
+ # pnpm
47
+ $ pnpm add nestjs-mailchannels
48
+ ```
49
+
50
+ ## Usage
51
+
52
+ ### Import the module
53
+
54
+ ```ts
55
+ import { Module } from '@nestjs/common'
56
+ import { MailChannelsModule } from 'nestjs-mailchannels'
57
+
58
+ @Module({
59
+ imports: [
60
+ MailChannelsModule.forRoot({
61
+ apiKey: 'YOUR-API-KEY'
62
+ })
63
+ ],
64
+ controllers: [],
65
+ providers: [],
66
+ exports: []
67
+ })
68
+ ```
69
+
70
+ ### Import the module Asynchronously
71
+
72
+ ```ts
73
+ import { Module } from '@nestjs/common'
74
+ import { MailChannelsModule } from 'nestjs-mailchannels'
75
+
76
+ @Module({
77
+ imports: [
78
+ MailChannelsModule.forRootAsync({
79
+ useFactory: async () => ({
80
+ apiKey: 'YOUR-API-KEY'
81
+ })
82
+ })
83
+ ],
84
+ controllers: [],
85
+ providers: [],
86
+ exports: []
87
+ })
88
+ ```
89
+
90
+ ### Controller for sending emails
91
+
92
+ ```ts
93
+ import { Controller, HttpException, Post } from "@nestjs/common";
94
+ import { MailChannelsService } from "nestjs-mailchannels";
95
+
96
+ @Controller()
97
+ export class EmailsController {
98
+ constructor(private readonly mailchannelsService: MailChannelsService) {}
99
+
100
+ @Post("emails/send")
101
+ async send() {
102
+ const { data, error } = await this.mailchannelsService.emails.send({
103
+ from: "Name <from@example.com>",
104
+ to: "to@example.net",
105
+ subject: "Test email",
106
+ text: "Hello from NestJS",
107
+ html: "<p>Hello from NestJS</p>"
108
+ });
109
+
110
+ if (error) {
111
+ throw new HttpException(error.message, error.statusCode || 500);
112
+ }
113
+
114
+ return data;
115
+ }
116
+
117
+ @Post("emails/queue")
118
+ async queue() {
119
+ const { data, error } = await this.mailchannelsService.emails.queue({
120
+ from: "Name <from@example.com>",
121
+ to: "to@example.net",
122
+ subject: "Test email",
123
+ text: "Hello from NestJS",
124
+ html: "<p>Hello from NestJS</p>"
125
+ });
126
+
127
+ if (error) {
128
+ throw new HttpException(error.message, error.statusCode || 500);
129
+ }
130
+
131
+ return data;
132
+ }
133
+ }
134
+ ```
135
+
136
+ ### Add your controller to your module
137
+
138
+ ```ts
139
+ import { Module } from '@nestjs/common'
140
+ import { MailChannelsModule } from 'nestjs-mailchannels'
141
+ import { EmailsController } from './emails/emails.controller.js'
142
+
143
+ @Module({
144
+ imports: [
145
+ MailChannelsModule.forRoot({
146
+ apiKey: 'YOUR-API-KEY'
147
+ })
148
+ ],
149
+ controllers: [EmailsController], // Add your controller here
150
+ providers: [],
151
+ exports: []
152
+ })
153
+ ```
154
+
155
+ ## License
156
+
157
+ [MIT License](LICENSE)
158
+
159
+ ## Development
160
+
161
+ <details>
162
+ <summary>Local development</summary>
163
+
164
+ ```sh
165
+ # Install dependencies
166
+ pnpm install
167
+
168
+ # Prepare environment
169
+ pnpm build
170
+
171
+ # Develop with the playground
172
+ pnpm playground:start
173
+
174
+ # Run Oxlint
175
+ pnpm lint
176
+
177
+ # Run Formatter
178
+ pnpm format
179
+
180
+ # Run Tests
181
+ pnpm test
182
+
183
+ # Run typecheck
184
+ pnpm test:types
185
+
186
+ # Release new version
187
+ pnpm release
188
+ ```
189
+
190
+ </details>
191
+
192
+ <!-- oxfmt-ignore-start -->
193
+
194
+ <!-- Badges -->
195
+ [npm-version-src]: https://img.shields.io/npm/v/nestjs-mailchannels/latest.svg
196
+ [npm-version-href]: https://npmjs.com/package/nestjs-mailchannels
197
+
198
+ [npm-downloads-src]: https://img.shields.io/npm/dm/nestjs-mailchannels.svg
199
+ [npm-downloads-href]: https://npmjs.com/package/nestjs-mailchannels
200
+
201
+ [license-src]: https://img.shields.io/npm/l/nestjs-mailchannels.svg
202
+ [license-href]: LICENSE
203
+
204
+ <!-- oxfmt-ignore-end -->
@@ -0,0 +1,5 @@
1
+ import { MAILCHANNELS_CONFIGURATION_OPTIONS } from "./mailchannels.constant.mjs";
2
+ import { MailChannelsOptions, MailChannelsOptionsAsync } from "./mailchannels.interface.mjs";
3
+ import { MailChannelsModule } from "./mailchannels.module.mjs";
4
+ import { MailChannelsService } from "./mailchannels.service.mjs";
5
+ export { MAILCHANNELS_CONFIGURATION_OPTIONS, MailChannelsModule, type MailChannelsOptions, type MailChannelsOptionsAsync, MailChannelsService };
package/dist/index.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import { MAILCHANNELS_CONFIGURATION_OPTIONS } from "./mailchannels.constant.mjs";
2
+ import { MailChannelsModule } from "./mailchannels.module.mjs";
3
+ import { t as MailChannelsService } from "./mailchannels.service-DlISywKM.mjs";
4
+ export { MAILCHANNELS_CONFIGURATION_OPTIONS, MailChannelsModule, MailChannelsService };
@@ -0,0 +1 @@
1
+ export declare const MAILCHANNELS_CONFIGURATION_OPTIONS = "MAILCHANNELS_CONFIGURATION";
@@ -0,0 +1,3 @@
1
+ // src/mailchannels.constant.ts
2
+ const MAILCHANNELS_CONFIGURATION_OPTIONS = "MAILCHANNELS_CONFIGURATION";
3
+ export { MAILCHANNELS_CONFIGURATION_OPTIONS };
@@ -0,0 +1,10 @@
1
+ import { FactoryProvider, ModuleMetadata } from "@nestjs/common";
2
+ import { MailChannelsClientOptions } from "@mailchannels/sdk";
3
+ export interface MailChannelsOptions extends MailChannelsClientOptions {
4
+ apiKey: string;
5
+ }
6
+ export interface MailChannelsOptionsAsync extends Pick<ModuleMetadata, "imports"> {
7
+ name?: string;
8
+ useFactory: (...args: unknown[]) => MailChannelsOptions | Promise<MailChannelsOptions>;
9
+ inject?: FactoryProvider<MailChannelsOptions>["inject"];
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { MailChannelsOptions, MailChannelsOptionsAsync } from "./mailchannels.interface.mjs";
2
+ import { DynamicModule } from "@nestjs/common";
3
+ export declare class MailChannelsModule {
4
+ static forRoot(options: MailChannelsOptions): DynamicModule;
5
+ static forRootAsync(options: MailChannelsOptionsAsync): DynamicModule;
6
+ }
@@ -0,0 +1,35 @@
1
+ import { MAILCHANNELS_CONFIGURATION_OPTIONS } from "./mailchannels.constant.mjs";
2
+ import { n as __decorate, t as MailChannelsService } from "./mailchannels.service-DlISywKM.mjs";
3
+ import { Module } from "@nestjs/common";
4
+ // src/mailchannels.module.ts
5
+ var _MailChannelsModule;
6
+ let MailChannelsModule = _MailChannelsModule = class MailChannelsModule {
7
+ static forRoot(options) {
8
+ return {
9
+ module: _MailChannelsModule,
10
+ providers: [{
11
+ provide: MAILCHANNELS_CONFIGURATION_OPTIONS,
12
+ useValue: options
13
+ }],
14
+ exports: [MailChannelsService]
15
+ };
16
+ }
17
+ static forRootAsync(options) {
18
+ const mailchannelsModuleOptions = {
19
+ provide: MAILCHANNELS_CONFIGURATION_OPTIONS,
20
+ useFactory: options.useFactory,
21
+ inject: options.inject || []
22
+ };
23
+ return {
24
+ module: _MailChannelsModule,
25
+ imports: options.imports,
26
+ providers: [mailchannelsModuleOptions],
27
+ exports: [MailChannelsService]
28
+ };
29
+ }
30
+ };
31
+ MailChannelsModule = _MailChannelsModule = __decorate([Module({
32
+ providers: [MailChannelsService],
33
+ exports: [MailChannelsService]
34
+ })], MailChannelsModule);
35
+ export { MailChannelsModule };
@@ -0,0 +1,32 @@
1
+ import { MAILCHANNELS_CONFIGURATION_OPTIONS } from "./mailchannels.constant.mjs";
2
+ import { Inject, Injectable } from "@nestjs/common";
3
+ import { MailChannels } from "@mailchannels/sdk";
4
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateMetadata.js
5
+ function __decorateMetadata(k, v) {
6
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
7
+ }
8
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
9
+ function __decorateParam(paramIndex, decorator) {
10
+ return function(target, key) {
11
+ decorator(target, key, paramIndex);
12
+ };
13
+ }
14
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
15
+ function __decorate(decorators, target, key, desc) {
16
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
18
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
19
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
20
+ }
21
+ // src/mailchannels.service.ts
22
+ let MailChannelsService = class MailChannelsService extends MailChannels {
23
+ constructor(options) {
24
+ super(options.apiKey, options);
25
+ }
26
+ };
27
+ MailChannelsService = __decorate([
28
+ Injectable(),
29
+ __decorateParam(0, Inject(MAILCHANNELS_CONFIGURATION_OPTIONS)),
30
+ __decorateMetadata("design:paramtypes", [Object])
31
+ ], MailChannelsService);
32
+ export { __decorate as n, MailChannelsService as t };
@@ -0,0 +1,5 @@
1
+ import { MailChannelsOptions } from "./mailchannels.interface.mjs";
2
+ import { MailChannels } from "@mailchannels/sdk";
3
+ export declare class MailChannelsService extends MailChannels {
4
+ constructor(options: MailChannelsOptions);
5
+ }
@@ -0,0 +1,2 @@
1
+ import "./mailchannels.constant.mjs";
2
+ export { t as MailChannelsService } from "./mailchannels.service-DlISywKM.mjs";
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "nestjs-mailchannels",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "NestJS module for the MailChannels Email API",
5
+ "license": "MIT",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "type": "module",
10
+ "main": "./dist/index.mjs",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.mts",
14
+ "default": "./dist/index.mjs"
15
+ }
16
+ },
17
+ "dependencies": {
18
+ "@mailchannels/sdk": "^1.9.1",
19
+ "@nestjs/common": "^12.4.0"
20
+ },
21
+ "devDependencies": {
22
+ "@nestjs/core": "^12.4.0",
23
+ "@types/node": "^26.6.6",
24
+ "oxfmt": "^0.77.0",
25
+ "oxlint": "^1.92.0",
26
+ "reflect-metadata": "^0.2.2",
27
+ "tsdown": "^0.23.7",
28
+ "typescript": "^6.0.3"
29
+ },
30
+ "engines": {
31
+ "node": ">=22.12.0"
32
+ },
33
+ "scripts": {
34
+ "build": "tsdown",
35
+ "playground:start": "cd playground && pnpm start",
36
+ "test:types": "tsc --noEmit",
37
+ "test": "node --run build && node --run test:types && node --test test/*.test.ts",
38
+ "lint": "oxlint",
39
+ "lint:fix": "oxlint --fix",
40
+ "format": "oxfmt --check",
41
+ "format:fix": "oxfmt",
42
+ "checks": "node --run test && node --run test:types &&node --run lint && node --run format",
43
+ "release": "node --run checks && changelogen --release --push --no-github",
44
+ "release:github": "changelogen gh release"
45
+ }
6
46
  }