Skip to content

Instantly share code, notes, and snippets.

@FikriRNurhidayat
FikriRNurhidayat / user.js
Created August 16, 2019 08:54
Creating authenticate methods on User Model
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const uniqueValidator = require('mongoose-unique-validator');
const jwt = require('jsonwebtoken');
const bcrypt = require('bcryptjs');
const userSchema = new Schema({
name: {
type: String,
max: 255,
@FikriRNurhidayat
FikriRNurhidayat / example.json
Created August 21, 2019 02:58
Example of Swagger JSON file
{
"swagger": "2.0",
"info": {
"description": "This is API Documentation.",
"version": "1.0.0",
"title": "Express Auth",
"contact": {
"email": "[email protected]"
},
"license": {
@FikriRNurhidayat
FikriRNurhidayat / codeChallenge-BE04Glints.md
Last active August 24, 2019 16:10
Glints Batch 4 - Backend Code Challenge

Challenge

Create TODO Apps.

Functional Requirement

  • Must be able to create todo entry
  • Must be able to update a todo entry
  • Must be able to delete a todo entry
  • Must be able to show a todo entry
  • Must be able to show all todo entry
  • Must be able to mark a todo entry into completed or not completed

Things must be fulfilled

var redirectButton = document.getElementById("redirectButton");
var loginButton = document.getElementById("loginButton");
var registerButton = document.getElementById("registerButton");
var loginForm = document.getElementById("loginForm");
var registerForm = document.getElementById("registerForm");
var logoutButton = document.getElementById("logoutButton");
var userLogin = document.getElementById("userLogin");
var registerRedirect = document.getElementById("registerRedirect");
var loginRedirect = document.getElementById("loginRedirect");
var isVerified = document.getElementById("helloVerified");
@FikriRNurhidayat
FikriRNurhidayat / index.html
Created August 27, 2019 03:37
Express Auth
<!DOCTYPE html>
<html>
<head>
<title>Express Auth</title>
<meta charset="UTF-8">
<meta name="description" content="Express Auth API">
<meta name="keywords" content="HTML,CSS,JavaScript">
<meta name="author" content="Fikri Rahmat Nurhidayat">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico'/>
process.env.NODE_ENV = 'test';
const chai = require('chai');
const chaiHttp = require('chai-http');
const server = require('../../src/server.js');
const should = chai.should();
const expect = chai.expect();
const User = require('../../src/models/user.js');
const faker = require('faker');
const jwt = require('jsonwebtoken');
#!/usr/bin/env node
/**
* Module dependencies.
*/
var app = require('../src/server.js');
var debug = require('debug')('random:server');
var http = require('http');
{
"swagger": "2.0",
"info": {
"description": "This is API Documentation.",
"version": "1.0.0",
"title": "Express Auth",
"contact": {
"email": "[email protected]"
}
},
@FikriRNurhidayat
FikriRNurhidayat / mailer.js
Created September 4, 2019 02:31
Example setup for nodemailer x sendgrid
const nodemailer = require('nodemailer');
const sgTransport = require('nodemailer-sendgrid-transport');
const { successResponse, errorsResponse } = require('./responseFormatter.js');
const option = {
auth: {
api_key: process.env.SENDGRID_API_KEY
}
}
const mongoose = require('mongoose');
const bcrypt = require('bcryptjs');
const jwt = require('jsonwebtoken');
const UserProfile = require('./userProfile.js');
var userSchema = new mongoose.Schema({
name: {
type: 'string',
required: true
},