Skip to content

Instantly share code, notes, and snippets.

View Sowed's full-sized avatar
💭
Focusing

iamcastelli Sowed

💭
Focusing
View GitHub Profile
@Sowed
Sowed / server.ts
Last active May 5, 2020 05:53
Migrating from Custom Express Server with `express-validator` to Next API Routes
import express, { Request, Response, NextFunction } from 'express';
import { check, validationResult, ValidationChain } from 'express-validator';
import bodyParser from 'body-parser';
import next from 'next';
const postMail = async (req: Request, res: Response): Promise<void> => {
// Use nodemailer to post the email. Setup mailer() with nodemailer
// and call it to Post an Email and return response
const mailResponse = await mailer(req.body);
res.json(mailResponse);