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: Deploy lambda functions | |
on: | |
push: | |
branches: | |
- main | |
- feature/milestone4 | |
jobs: | |
deploy-dev: |
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
// create a node | |
class ListNode { | |
constructor(data, next = null) { | |
this.data = data; | |
this.next = next; | |
} | |
} | |
// create a node list | |
class LinkedList { |
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
import Authentication from './../lib/Authentication.js'; | |
class MyBank { | |
login = (req, res, next) => { | |
const userTypes = ['admin', 'agent', 'customer']; | |
let currentUserType = userTypes[Math.floor(Math.random() * userTypes.length)]; | |
let payload = { | |
id : 'your unique id', | |
// some more user related data | |
} |
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
import { Router } from 'express'; | |
import Controller from './../controllers/index.js'; | |
import AuthenticateRoles from './../middlewares/AuthenticateRoles.js'; | |
var router = Router(); | |
// To make user login. | |
router.get('/login', Controller.login) | |
// to get the account details | |
router.get('/account', AuthenticateRoles.Customer, Controller.getAccount) |
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
import Authentication from './../lib/Authentication.js'; | |
class AuthRoles { | |
Authenticate = async (req, res, next, role) => { | |
try { | |
let decode = await Authentication.authenticate(req.headers.authorization, role) | |
req.user = decode; | |
next(); | |
} catch (error) { | |
if(error.name == 'TokenExpiredError'){ |
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
import JWT from 'jsonwebtoken'; | |
class Authentication { | |
authenticate = (token, role) => { | |
return new Promise((resolve, reject) => { | |
jwt.verify(token, role, function(err, decoded) { | |
if (err) { | |
reject(err); | |
} else { | |
resolve(decoded) |
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
var messages = require('../static/StatusMessages'); | |
var error_pointer = 'codes' | |
function SuccessResponse (code, res, responseObj, message) { | |
var response = {}; | |
response.code = code; | |
response.result = responseObj; | |
if (code !== 200) { | |
response.message = messages[error_pointer][code]; | |
} else { | |
response.message = message; |