Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Raul Torrefiel Jr. alur222

🎯
Focusing
  • Cebu, Philippines
View GitHub Profile
@alur222
alur222 / authVerify.js
Last active Apr 2, 2019
verfying token authenticity from localStorage
View authVerify.js
// replace LS_ITEM_NAME with your localstorage item name
// REACT_APP_BACKEND_HOST
// server should accept custom header "x-access-token"
export const AuthVerify = async () => {
const token = localStorage.getItem(LS_ITEM_NAME);
if (!token) {
return Promise.reject(false);
}
return axios.request({
@alur222
alur222 / sample_test.js
Created Aug 7, 2018
sample mocha, chai and sinon test file
View sample_test.js
process.env.NODE_ENV = 'test';
const chai = require('chai');
const should = chai.should();
const chaiHttp = require('chai-http');
chai.use(chaiHttp);
const server = require('../../src/app.js');
describe('routes : index', () => {
@alur222
alur222 / gulpfile.js
Created Aug 7, 2018
Sample gulp file for node js development with auto reload
View gulpfile.js
const gulp = require('gulp');
const spawn = require('child_process').spawn;
let node;
function server() {
if (node) {
node.kill();
}
node = spawn('npm', ['run', 'runserver'], {stdio: 'inherit'});
node.on('close', function (code) {