Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update repository #37

Merged
merged 3 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 0 additions & 146 deletions .eslintrc.js

This file was deleted.

24 changes: 0 additions & 24 deletions .github/stale.yml

This file was deleted.

30 changes: 21 additions & 9 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,33 @@
name: Node.js CI

on: [push, pull_request]

jobs:
build:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"
- run: npm ci
- run: npm run test

build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm test
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run compile
3 changes: 1 addition & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018 Feathers
Copyright (c) 2025 Feathers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

76 changes: 42 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# feathers-mailer

[![Node.js CI](https://github.com/feathersjs-ecosystem/feathers-mailer/actions/workflows/node.js.yml/badge.svg)](https://github.com/feathersjs-ecosystem/feathers-mailer/actions/workflows/node.js.yml)
[![Dependency Status](https://img.shields.io/david/feathersjs-ecosystem/feathers-mailer.svg?style=flat-square)](https://david-dm.org/feathersjs-ecosystem/feathers-mailer)
![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/feathersjs-ecosystem/feathers-mailer)
[![Download Status](https://img.shields.io/npm/dm/feathers-mailer.svg?style=flat-square)](https://www.npmjs.com/package/feathers-mailer)

> Feathers mailer service using [`nodemailer`](https://github.com/nodemailer/nodemailer)
Expand All @@ -14,14 +14,13 @@ npm install feathers-mailer --save

If using a [transport plugin](https://nodemailer.com/transports/), install the respective module.


## API

```js
const mailer = require('feathers-mailer');
```
```ts
import { Service } = from 'feathers-mailer';

### `app.use('/emails', mailer(transport, defaults))`
app.use('/emails', new Service(transport, defaults));
```

- `transport` can be either [SMTP options](https://nodemailer.com/smtp/#general-options) or a [transport plugin](https://nodemailer.com/transports/) with associated options.
- `defaults` is an object that defines default values for mail options.
Expand All @@ -35,8 +34,8 @@ See [here](https://nodemailer.com/message/#commmon-fields) for possible fields o
## Example with SMTP (ethereal)

```js
const mailer = require('feathers-mailer');
const nodemailer = require('nodemailer');
import { Service } from "feathers-mailer";
import nodemailer from "nodemailer";

(async function (app) {
const account = await nodemailer.createTestAccount(); // internet required
Expand All @@ -48,51 +47,60 @@ const nodemailer = require('nodemailer');
requireTLS: true,
auth: {
user: account.user, // generated ethereal user
pass: account.pass // generated ethereal password
}
pass: account.pass, // generated ethereal password
},
};

// Register service and setting default From Email
app.use('mailer', mailer(transporter, { from: account.user }));
app.use("mailer", new Service(transporter, { from: account.user }));

// Use the service
const email = {
to: 'president@mars.com',
subject: 'SMTP test',
html: 'This is the email body'
to: "president@mars.com",
subject: "SMTP test",
html: "This is the email body",
};

await app.service('mailer').create(email)
console.log(`Preview URL: ${nodemailer.getTestMessageUrl(info)}`)
})(app)
await app.service("mailer").create(email);
console.log(`Preview URL: ${nodemailer.getTestMessageUrl(info)}`);
})(app);
```

## Example with Mandrill

```js
const mailer = require('feathers-mailer');
const mandrill = require('nodemailer-mandrill-transport');
import { Service } from "feathers-mailer";
import mandrill from "nodemailer-mandrill-transport";

// Register the service, see below for an example
app.use('/mailer', mailer(mandrill({
auth: {
apiKey: process.env.MANDRILL_API_KEY
}
})));
app.use(
"/mailer",
new Service(
mandrill({
auth: {
apiKey: process.env.MANDRILL_API_KEY,
},
})
)
);

// Use the service
const email = {
from: 'FROM_EMAIL',
to: 'TO_EMAIL',
subject: 'Mandrill test',
html: 'This is the email body'
from: "FROM_EMAIL",
to: "TO_EMAIL",
subject: "Mandrill test",
html: "This is the email body",
};

app.service('mailer').create(email).then(function (result) {
console.log('Sent email', result);
}).catch(err => {
console.log(err);
});
app
.service("mailer")
.create(email)
.then(function (result) {
console.log("Sent email", result);
})
.catch((err) => {
console.log(err);
});
```

## Prevent mail to be treated as spam
Expand All @@ -119,6 +127,6 @@ A use case for this, could be a multitenancy application. There the reply domain

## License

Copyright (c) 2018
Copyright (c) 2025

Licensed under the [MIT license](LICENSE).
12 changes: 12 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommended,
{
rules: {
"@typescript-eslint/no-explicit-any": "off",
}
}
);
Loading
Loading