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

feat: update email-templates and extend functionality #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2016 Jose Luis
Copyright (c) 2022 Pascal Malbranche

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 Down
106 changes: 54 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,81 +19,83 @@ This is an example using parse server as express module:
```js
"use strict";

const Express = require('express');
const ParseServer = require('parse-server').ParseServer;
const Express = require("express");
const ParseServer = require("parse-server").ParseServer;

const app = Express();
const APP_PORT = 1337;

let options = {

};
let options = {};

let api = new ParseServer({
appName: "Parse Test",
appId: "12345",
masterKey: "abcde12345",
serverURL: "http://localhost:1337/parse",
publicServerURL: "http://localhost:1337/parse",
databaseURI: "mongodb://user:pass@host:27017/parse",
port: APP_PORT,
//This is the config for email adapter
emailAdapter: {
module: "simple-parse-smtp-adapter",
options: {
service:'Gmail', // required
clientId:'your_clientid_get_from_console_google_developers',
clientSecret:'your_clientsecret_get_from_console_google_developers',
refreshToken:'your_refresh_token_get_from_console_google_developers',
accessToken:'your_access_token_get_from_console_google_developers',
fromAddress: '[email protected]',
user: '[email protected]', //#"required for service SMTP"
//password: 'AwesomePassword', //#"required for service SMTP"
//host: 'your.smtp.host', //#"required for service SMTP"
//isSSL: true, //True or false if you are using ssl //#"required for service SMTP"
//port: 465, //SSL port or another port //#"required for service SMTP"
name: 'your domain name', // optional, used for identifying to the server
//Somtimes the user email is not in the 'email' field, the email is search first in
//email field, then in username field, if you have the user email in another field
//You can specify here
emailField: 'username',
templates: {
//This template is used only for reset password email
resetPassword: {
//Path to your template
template: __dirname + '/views/email/reset-password',
//Subject for this email
subject: 'Reset your password'
},
verifyEmail: {
template: __dirname + '/views/email/verify-email',
subject: 'Verify Email'
}
}
}
}
appName: "Parse Test",
appId: "12345",
masterKey: "abcde12345",
serverURL: "http://localhost:1337/parse",
publicServerURL: "http://localhost:1337/parse",
databaseURI: "mongodb://user:pass@host:27017/parse",
port: APP_PORT,
//This is the config for email adapter
emailAdapter: {
module: "simple-parse-smtp-adapter",
options: {
service: "Gmail", // required
clientId: "your_clientid_get_from_console_google_developers",
clientSecret: "your_clientsecret_get_from_console_google_developers",
refreshToken: "your_refresh_token_get_from_console_google_developers",
accessToken: "your_access_token_get_from_console_google_developers",
fromAddress: "[email protected]",
user: "[email protected]", //#"required for service SMTP"
//password: 'AwesomePassword', //#"required for service SMTP"
//host: 'your.smtp.host', //#"required for service SMTP"
//isSSL: true, //True or false if you are using ssl //#"required for service SMTP"
//port: 465, //SSL port or another port //#"required for service SMTP"
name: "your domain name", // optional, used for identifying to the server
//Somtimes the user email is not in the 'email' field, the email is search first in
//email field, then in username field, if you have the user email in another field
//You can specify here
emailField: "username",
// Define the extension of your template files, by default handlebars is used.
extension: "handlebars",
templates: {
//This template is used only for reset password email
resetPassword: {
//Path to your template
template: __dirname + "/views/email/reset-password",
//Subject for this email
subject: "Reset your password",
},
verifyEmail: {
template: __dirname + "/views/email/verify-email",
subject: "Verify Email",
},
},
},
},
});

/**
* Parse Server endpoint
*/
app.use('/parse', api);
app.use("/parse", api);

app.listen(APP_PORT, function () {
console.log(`Parse Server Ready and listening on port ${APP_PORT}`);
console.log(`Parse Server Ready and listening on port ${APP_PORT}`);
});
```

### Template
The path you pass to the email adapter must be a directory and not a file, this path must contain 2 mandatory files `html.jade` and `style.less` you can do your template as you like with the [CSS rules that emails supports](https://www.campaignmonitor.com/css/) in the template you can use 3 variables:

The path you pass to the email adapter must be a directory and not a file, this path must contain a file named `index.handlebars`. If you use another template engine, define the adapter option `extension`. For engine sources visit [consolidate.js](https://github.com/tj/consolidate.js/#supported-template-engines) which is the used template engine.
Inside templates, you can use the following variables:

- appName //This is the name of your parse app
- link //This is the link for reset the password
- user //This is a Parse object with the current user, so you can use any field in your User class of parse for example the user name `#{user.get('username')}`

### Contributing
This module is pull request friendly in the develop branch feel free of send new features or bug fixes.

If you find a bug please open an issue.
This module is a private fork and not a maintained public module, however this repo is pull request friendly and all backwards compatible contributions are welcome.
Free to [open an issue](https://github.com/music-bat/mbat/issues/new) in our main repo. Please also read through the [Code of Conduct](https://github.com/music-bat/mbat/blob/main/CODE_OF_CONDUCT.md) of our [main repo](https://github.com/music-bat/mbat/blob/main/CODE_OF_CONDUCT.md).

### License MIT
Loading