Best Practice, Blogs, Guides, Lists, Web Design Inspiration & Front-end Development Tools
This file contains hidden or 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
| { | |
| "name": "suryavp", | |
| "version": "1.0.0", | |
| "description": "", | |
| "main": "server.js", | |
| "scripts": { | |
| "test": "mocha --timeout 100000" | |
| }, | |
| "author": "", | |
| "license": "ISC", |
This file contains hidden or 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 User = require('../../models/User') | |
| const app = require('../../server') // my express app | |
| const chai = require('chai'); | |
| const chaiHttp = require('chai-http'); | |
| const { expect } = require('chai'); | |
| const should = chai.should(); | |
| describe('Auth', () => { | |
| beforeEach((done) => { |
This file contains hidden or 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 chai = require('chai'); | |
| const chaiHttp = require('chai-http'); | |
| chai.use(chaiHttp); | |
| require('./api/user.test') | |
| require('./api/auth.test') |
This file contains hidden or 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 = { | |
| userImage: "https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png", | |
| }; |
This file contains hidden or 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 User = require('../models/User'); | |
| const {jwtSecret} = require('../config/SecretToken') | |
| const jwt = require("jsonwebtoken"); | |
| const bcrypt = require('bcryptjs'); | |
| module.exports = { | |
| generateToken: (userData) => { | |
| const payload = { | |
| user: { |
This file contains hidden or 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 User = require("../../models/User"); | |
| const createError = require('http-errors') | |
| const authFunctions = require("../../helper/authFunctions"); | |
| module.exports = { | |
| login: async (req, res, next) => { | |
| const { | |
| email, | |
| password | |
| } = req.body; |
This file contains hidden or 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 express = require('express'); | |
| const AuthController = require('../../controllers/api/AuthController'); | |
| const router = express.Router(); | |
| router.post('/login',AuthController.login) | |
| module.exports = router; |
This file contains hidden or 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 mongoose = require('mongoose') | |
| const dotenv = require("dotenv") | |
| dotenv.config() | |
| const URI = process.env.DB_URL | |
| const options = { | |
| useNewUrlParser: true, | |
| useFindAndModify: false, | |
| useCreateIndex: true, |
This file contains hidden or 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 express = require('express') | |
| const createError = require('http-errors') | |
| const dotenv = require("dotenv") | |
| const connectDB = require('./services/db') | |
| dotenv.config() | |
| const app = express() | |
| app.use(express.json()) |
NewerOlder