Skip to content

Instantly share code, notes, and snippets.

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

Victor Awotidebe debelistic

🏠
Working from home
View GitHub Profile
@debelistic
debelistic / signinHelper.ts
Created August 9, 2022 10:24
helper for role based signin
import router from 'next/router';
import { USER_ROLES } from './';
export function useLoginRouter({ role, accessToken }: { role: string; accessToken: string; }){
if (role === USER_ROLES.SCOUT) {
return router.push(process.env.NEXT_PUBLIC_SCOUT_URL + '?userId=' + accessToken);
} else if (role === USER_ROLES.OWNER) {
return router.push(process.env.NEXT_PUBLIC_OWNER_URL + '?userId=' + accessToken);
} else if (role === USER_ROLES.SERVICE_PROVIDER) {
@debelistic
debelistic / app.domain.com
Created July 29, 2020 14:17
Nginx Server block Configuration
server {
listen 80;
server_name app.domain.com;
location / {
proxy_pass http://localhost:7000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
@debelistic
debelistic / create_pdf.js
Last active July 29, 2020 14:02
Creating PDF files with Nodejs
const fs = require('fs')
const path = require('path')
const utils = require('util')
const puppeteer = require('puppeteer')
const hb = require('handlebars')
const readFile = utils.promisify(fs.readFile)
const fileName = './sample.pdf'
function getFile() {
<!doctype html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta http-equiv="Content-Language" content="en" />
<meta name="msapplication-TileColor" content="#2d89ef">
<meta name="theme-color" content="#4188c9">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
@debelistic
debelistic / index.js
Created December 31, 2019 10:40
default server file
import express from 'express';
import { config } from 'dotenv';
import routes from './routes';
config();
const app = express();
app.use(routes);
app.listen();
@debelistic
debelistic / list.js
Created October 14, 2019 11:25
Sample model in sequelize
'use strict';
module.exports = (sequelize, DataTypes) => {
const list = sequelize.define('list', {
item: DataTypes.STRING,
priority: DataTypes.ENUM('very important', 'important', 'maybe'),
quantity: DataTypes.INTEGER,
UserId: DataTypes.INTEGER
}, {});
list.associate = function(models) {
// associations can be defined here
@debelistic
debelistic / user.js
Last active December 31, 2019 11:04
Sample User model in sequelize ORM with association
module.exports = (sequelize, DataTypes) => {
const User = sequelize.define('User', {
username: {
type: DataTypes.STRING,
allowNull: false
},
password: {
type: DataTypes.STRING,
allowNull: false
},
@debelistic
debelistic / config.js
Created September 6, 2019 15:41
Sequelize environment variables configuration
import { config } from 'dotenv';
config();
module.exports = {
development: {
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
host: process.env.DB_HOST,
@debelistic
debelistic / .sequelizerc
Last active September 6, 2019 15:18
A sequelizerc configuration for production and other environments
const path = require('path');
const dotenv = require('dotenv');
dotenv.config();
if(process.env.NODE_ENV != 'production'){
require('@babel/register');
module.exports = {
"config": path.resolve("./src/database", "config.js"),
"models-path": path.resolve("./src/models"),
@debelistic
debelistic / index.js
Last active September 4, 2019 21:34
Index routes file
import express from 'express';
import listRouter from './listRoutes';
const Router = express.Router();
Router.get('/', (req, res) => {
res.status(200).send({
message: 'Welcome, add your wish'
});
})