Skip to content

Instantly share code, notes, and snippets.

0x5ad29c5eFf82dAB06267F44c7Ef1864004A7605e
// Initializes the `/mailer` service on path `/mailer`
const hooks = require('./mailer.hooks');
const Mailer = require('feathers-mailer');
const smtpTransport = require('nodemailer-smtp-transport');
module.exports = function (app) {
app.use('/mailer', Mailer(smtpTransport({
host: 'email-smtp.us-east-1.amazonaws.com',
secure: true,
auth: {
// Initializes the `authmanagement` service on path `/authmanagement`
const authManagement = require('feathers-authentication-management');
const hooks = require('./authmanagement.hooks');
const notifier = require('./notifier');
module.exports = function (app) {
// Initialize our service with any options it requires
app.configure(authManagement(notifier(app)));
@ImreC
ImreC / notifier.js
Last active February 17, 2018 19:40
module.exports = function(app) {
function getLink(type, hash) {
const url = 'http://localhost:3030/' + type + '?token=' + hash
return url
}
function sendEmail(email) {
return app.service('mailer').create(email).then(function (result) {
console.log('Sent email', result)
const { authenticate } = require('@feathersjs/authentication').hooks;
const verifyHooks = require('feathers-authentication-management').hooks;
const accountService = require('../authmanagement/notifier');
const {
hashPassword, protect
} = require('@feathersjs/authentication-local').hooks;
module.exports = {
before: {
<html>
<body>
<p id = "info">
Sending token
</p>
<script>
var url = new URL(window.location.href);
var token = url.searchParams.get("token");
var obj = {
action: 'verifySignupLong',
before: {
all: [],
find: [ authenticate('jwt') ],
get: [ authenticate('jwt') ],
create: [
hashPassword(),
verifyHooks.addVerification()
],
update: [
commonHooks.disallow('external')
@ImreC
ImreC / package.json
Created May 8, 2018 13:32
Package.json for graphql tutorial
{
"name": "tutorial-graphql",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "nodemon ./index.js --exec babel-node",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Imre Gelens",
@ImreC
ImreC / .babelrc
Created May 8, 2018 13:41
Graphql tutorial
{
"presets": [
"es2015"
],
"plugins": [
"syntax-async-functions",
"transform-regenerator"
]
}
@ImreC
ImreC / mongoose.js
Created May 8, 2018 13:47
Graphql tutorial
import mongoose from "mongoose";
const Schema = mongoose.Schema;
const productSchema = new Schema({
name: {type:String},
description: {type:String},
image: {type:String},
price: {type:Number}
}, {collection:"products"}); // Defining the collection is redundant in this case.