Skip to content

Instantly share code, notes, and snippets.

View luishrd's full-sized avatar
🏠
Working from home

Luis Hernandez luishrd

🏠
Working from home
View GitHub Profile
const mongoose = require('mongoose');
const bcrypt = require('bcrypt');
const userSchema = new mongoose.Schema({
username: {
type: String,
required: true,
unique: true,
lowercase: true,
// normalize all users to lowercase
@luishrd
luishrd / index.js
Last active September 29, 2024 00:25
CS9 Building APIs Notes
// inside the middleware folder
module.exports = {
greeter,
logger,
errorHandler,
};
function greeter(name) {
return function(req, res, next) {
@luishrd
luishrd / Character.js
Last active May 10, 2018 21:30
MongoDB Sprint
const mongoose = require('mongoose');
const ObjectId = mongoose.Schema.Types.ObjectId;
const Character = mongoose.Schema({
name: { type: String, required: true },
edited: Date,
created: Date,
gender: String,
height: String,
hair_color: String,
@luishrd
luishrd / User.js
Last active December 27, 2023 22:31
Auth Sprint
const mongoose = require('mongoose');
const bcrypt = require('bcrypt'); //< ===========
const userSchema = new mongoose.Schema({
username: {
type: String,
required: true,
unique: true,
lowercase: true, // Kyle => kyle
},
@luishrd
luishrd / App.js
Last active June 5, 2022 21:50
JWT Server, all other files remain the same
// /src/App.js
import React, { Component } from 'react';
import { Route, withRouter } from 'react-router-dom';
import logo from './logo.svg';
import './App.css';
import Signin from './auth/Signin';
import Users from './users/Users';
@luishrd
luishrd / index.js
Last active May 25, 2018 16:46
Client Testing
const utilities = require('../index');
describe.skip('default', () => {
it('run the tests', () => {});
});
describe('add function', () => {
// afterAll(() => {
// console.log('after all ran');
// });
@luishrd
luishrd / .gitignore
Last active June 27, 2018 16:40
React Testing
// /.gitignore
# See https://help.github.com/ignore-files/ for more about ignoring files.
# dependencies
/node_modules
# testing
/coverage
@luishrd
luishrd / .gitignore
Created May 24, 2018 18:10
Server Testing
node_modules
.DS_Store
.vscode
@luishrd
luishrd / UserModel.js
Last active July 9, 2018 06:20
CS10 - Auth with Sessions
// ./auth/UserModel.js
const mongoose = require('mongoose');
const bcrypt = require('bcrypt');
const userSchema = new mongoose.Schema({
username: {
type: String,
unique: true,
required: true,
@luishrd
luishrd / App.js
Last active July 18, 2019 02:43
CS10 - JWT Auth
// ./client/src/App.js
import React, { Component } from 'react';
import { Route, withRouter } from 'react-router-dom';
import logo from './logo.svg';
import './App.css';
import Signin from './auth/Signin';
import Users from './users/Users';