This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function authRouter(fastify, opts) { | |
fastify.post('/api/v1/generateAccessToken', async (request, reply) => { | |
const { email, username, userId } = request.body; | |
if (!email || !username || !userId) { | |
reply.status(400).send({ error: true, msg: 'Mandatory fields are missing' }); | |
} | |
//SET DB level checks if any | |
const token = fastify.jwt.sign({ email, username, userId }, { expiresIn: 86400 }); | |
reply.send({ token, email, userId }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fp = require('fastify-plugin'); | |
module.exports = fp(async (fastify) => { | |
fastify.decorate('authenticate', async (request, reply) => { | |
try { | |
await request.jwtVerify(); | |
} catch (err) { | |
reply.send(err); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async function(fastify, opts) { | |
fastify.get( | |
"/api/validateAccessToken", | |
{ | |
preValidation: [fastify.authenticate] | |
}, | |
async function(req, res) { | |
res.status(200).send({msg: "Success"}); | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fastify = require('fastify')({ logger: true }); | |
const authRouter = require('./router/authRouter'); | |
const router = require('./router/router'); | |
fastify.register(require('fastify-jwt'), { | |
secret: "test@&%%PUY", // use .env for this | |
}); | |
//cross-origin | |
fastify.register(require('fastify-cors'), { | |
origin: '*', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ReactDOM.render(React.createElement(Picker, | |
{ autoFocus: true,showSkinTones: 'false', | |
emojiSize: 19, | |
set: "twitter", | |
emoji: 'male-technologist', | |
perLine: '8', | |
title: 'Emojis', | |
onClick: function onClick(e, emoji) {app.handleEmojiClick(emoji,e)}}), | |
document.getElementById('root')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { emojiIndex,Emoji } from 'emoji-mart'; | |
window.emojiIndex = emojiIndex; | |
import { Picker } from 'emoji-mart' | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
window.ReactDOM = ReactDOM; | |
window.React = React; | |
window.Picker = Picker; | |
window.EmojiHandler = Emoji; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { emojiIndex,Emoji } from 'emoji-mart'; | |
window.emojiIndex = emojiIndex; | |
import { Picker } from 'emoji-mart' | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
window.ReactDOM = ReactDOM; | |
window.React = React; | |
window.Picker = Picker; | |
window.EmojiHandler = Emoji; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('jsdom-global')(); | |
const fs = require('fs'); | |
global.document = window.document; | |
var htmlString = fs.fs.readFileSync('demo.html').toString(); | |
document.documentElement.innerHTML = htmlString; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
emojiToUnicode=function (str){ | |
var emojiRegexp = /([\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2694-\u2697]|\uD83E[\uDD10-\uDD5D])/g; | |
if(!str) | |
return; | |
try{ | |
var new_str= str.match(emojiRegexp); | |
for(var emoj in new_str){ | |
var emojmessage = new_str[emoj]; | |
var index = str.indexOf(emojmessage); | |
if(index === -1) |