Node.js 8 LTS
SKGNodejs Meetup - http://kostasbariotis.com
Node.js Release Plan
SKGNodejs Meetup
Node.js 8 Honorable Changes
SKGNodejs Meetup
Async Functions
SKGNodejs Meetup
async function loginController(req, res, next) {
const { email, password } = req.email;
try {
if (!email || !password) {
throw new WrongCredentialsError();
}
const user = await fetchUserByEmail(email);
if (user.password !== hashPassword(req.password)) {
throw new WrongCredentialsError();
}
await markLoggedInTimestamp(user.userId);
await sendEmail(user.userId);
const token = await generateJWT(user);
res.json({ success: true, token });
} catch (err) {
if (err instanceof WrongCredentialsError) {
res.json({ success: false, error: 'Invalid email and/or password' })
} else if (err instanceof DBConnectionError || err instanceof EmailError) {
res.json({ success: false, error: 'Unexpected error, please try again' });
} else {
res.json({ success: false })
}
}
}
Source: Async/Await - A thorough example
SKGNodejs Meetup
Object values/entries
const object = {
file: 'name',
}
console.log('Object.keys :', Object.keys(object))
console.log('Object.values :', Object.values(object))
console.log('Object.entries :', Object.entries(object))
// Object.keys : [ 'file' ]
// Object.values : [ 'name' ]
// Object.entries : [ [ 'file', 'name' ] ]
SKGNodejs Meetup
Trailing commas
function exec(param1, param2) {
return `${param1}, ${param2}`;
}
function exec(param1, param2,) {
return `${param1}, ${param2}`;
}
function exec(
param1,
param2,
) {
return `${param1}, ${param2}`;
}
SKGNodejs Meetup
That's all basically, thank you for your time. I know I wasn't supposed to put long text on my slides but what the heck? Who make the rules? Those are my slides and I can do whatever I want. Is that ok with you? Well guess what? I don't even car.
SKGNodejs Meetup
Node.js 8 LTS
By Kostas Bariotis
Node.js 8 LTS
- 1,477