Skip to content

Instantly share code, notes, and snippets.

View hzburki's full-sized avatar
👋
Hi! Any questions?

Haseeb Burki hzburki

👋
Hi! Any questions?
View GitHub Profile
@hzburki
hzburki / ssl.config
Last active August 11, 2020 13:10
File for Configuring SSL Certificate to Elastic Beanstalk - Single Instance
Resources:
sslSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
ToPort: 443
FromPort: 443
CidrIp: 0.0.0.0/0
@hzburki
hzburki / buildspec.yml
Created December 15, 2018 13:33
buildspec.yml file for uploading static site to AWS S3 with CodeBuild
version: 0.2
phases:
install:
commands:
- npm i npm@latest -g
- pip install --upgrade pip
- pip install --upgrade awscli
pre_build:
commands:
@hzburki
hzburki / serverless.yml
Created April 16, 2019 07:59
.yml file for blog post serverless project
# Happy Coding!
service: serverless-node
provider:
name: aws
runtime: nodejs8.10
stage: dev
region: eu-west-1
@hzburki
hzburki / app.js
Last active April 16, 2019 08:36
app.js for Serverless Node Project - Serverless Blog
const express = require('express')
const bodyParser = require('body-parser')
const serverless = require('serverless-http')
const app = express()
/* Body Parser */
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
@hzburki
hzburki / dbConn.js
Created April 16, 2019 08:55
Re-usable database connections in serverless blog project
const Sequelize = require('sequelize')
const sequelize = new Sequelize(
process.env.DB_NAME,
process.env.DB_USERNAME,
process.env.DB_PASSWORD,
{
host: process.env.DB_HOST,
port: process.env.DB_PORT,
dialect: process.env.DB_DIALECT,
@hzburki
hzburki / database.providers.ts
Last active July 14, 2019 14:58
For providing database connection details to Sequelize with NestJs
import { Sequelize } from 'sequelize-typescript';
/**
* SEQUELIZE variable is stored in a file named
* 'constants' so it can be easily reused anywhere
* without being subject to human error.
*/
import { SEQUELIZE } from '../utils/constants';
import { User } from '../user/user.entity';
@hzburki
hzburki / database.module.ts
Created July 14, 2019 14:59
Database Module for NestJS Sequelize Blog
import { Module } from '@nestjs/common';
import { databaseProviders } from './database.providers';
@Module({
providers: [...databaseProviders],
exports: [...databaseProviders],
})
export class DatabaseModule {}
@hzburki
hzburki / user.entity.js
Created July 14, 2019 15:06
User entity model - NestJS SequelizeJS Blog
import {
Table,
Column,
Model,
DataType,
CreatedAt,
UpdatedAt,
DeletedAt,
} from 'sequelize-typescript';
import { IDefineOptions } from 'sequelize-typescript/lib/interfaces/IDefineOptions';
@hzburki
hzburki / user.provider.ts
Created July 14, 2019 15:08
Exporting user entity model so it can be injected into NestJS services - NestJS SequelizeJS
import { User } from './user.entity';
import { USER_REPOSITORY } from '../utils/constants';
export const userProviders = [
{
provide: USER_REPOSITORY,
useValue: User,
},
];
@hzburki
hzburki / createUserDto.ts
Created July 14, 2019 15:11
Data transfer object for creating users - NestJS SequelizeJS blog
export class CreateUserDto {
readonly name: string;
readonly age: number;
readonly email: string;
}