Skip to content

Instantly share code, notes, and snippets.

@tanveerprottoy
tanveerprottoy / main.go
Created September 15, 2022 14:09
main.go
package main
import "txp/restapistarter/app"
func main() {
app := new(app.App)
app.InitComponents()
app.Run()
}
@tanveerprottoy
tanveerprottoy / app-provider.repository.ts
Created May 3, 2022 12:23
app-provider.repository.ts
import { Injectable } from "@nestjs/common";
import { CreateAppDto } from "./create-app.dto";
import { App } from "./data/entities/app.entity";
import { v4 as uuidv4 } from 'uuid';
import { DbDataOpsInstance } from "./libs/dynamodb";
import { DeleteCommandInput, GetCommandInput, PutCommand, PutCommandInput, ScanCommandInput, UpdateCommandInput } from "@aws-sdk/lib-dynamodb";
import { Constants } from "./constants";
import { DbClientsProvider } from "./data/db-clients.provider";
@Injectable()
@tanveerprottoy
tanveerprottoy / db-clients.provider.ts
Created May 3, 2022 12:18
db-clients.provider.ts
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";
import { Injectable } from "@nestjs/common";
@Injectable()
export class DbClientsProvider {
public dbClient: DynamoDBClient;
public dbDocumentClient: DynamoDBDocumentClient
constructor() {
@tanveerprottoy
tanveerprottoy / app.schema.ts
Last active May 3, 2022 11:49
app.schema.ts
import { CreateTableInput } from "@aws-sdk/client-dynamodb";
import { Constants } from "../../constants";
import { DbControlOpsInstance } from "../../libs/dynamodb";
const appTableParams: CreateTableInput = {
TableName: "Apps",
KeySchema: [
{
AttributeName: "id",
KeyType: "HASH"
@tanveerprottoy
tanveerprottoy / app.service.ts
Last active May 3, 2022 12:00
app.service.ts
import { Injectable } from '@nestjs/common';
import { AppRepository } from './app.repository';
import { CreateAppDto } from './create-app.dto';
@Injectable()
export class AppService {
constructor(
private readonly repository: AppRepository
) { }
@tanveerprottoy
tanveerprottoy / app.repository.ts
Last active May 3, 2022 11:41
app.repository.ts
import { Injectable } from "@nestjs/common";
import { CreateAppDto } from "./create-app.dto";
import { App } from "./data/entities/app.entity";
import { v4 as uuidv4 } from 'uuid';
import { DbDataOpsInstance } from "./libs/dynamodb";
import { DeleteCommandInput, GetCommandInput, PutCommandInput, ScanCommandInput, UpdateCommandInput } from "@aws-sdk/lib-dynamodb";
import { Constants } from "./constants";
@Injectable()
export class AppRepository {
import { CreateTableCommand, CreateTableInput, DeleteTableCommand, DeleteTableInput, DescribeTableCommand, DescribeTableInput, ListTablesCommand, UpdateTableCommand, UpdateTableInput } from "@aws-sdk/client-dynamodb";
import { Logger } from "@nestjs/common";
import { DbClientsInstance } from "./db.clients";
class DbControlOps {
private static instance: DbControlOps;
private constructor() {
console.log('DbControlOps init');
if(DbControlOps.instance) {
import { BatchExecuteStatementCommand, BatchExecuteStatementCommandInput, BatchGetCommand, BatchGetCommandInput, DeleteCommand, DeleteCommandInput, ExecuteStatementCommand, ExecuteStatementCommandInput, ExecuteTransactionCommand, ExecuteTransactionCommandInput, GetCommand, GetCommandInput, PutCommand, PutCommandInput, QueryCommand, QueryCommandInput, ScanCommand, ScanCommandInput, UpdateCommand, UpdateCommandInput } from "@aws-sdk/lib-dynamodb";
import { Logger } from "@nestjs/common";
import { DbClientsInstance } from "./db.clients";
class DbDataOps {
private static instance: DbDataOps;
private constructor() {
console.log('DbDataOps init');
if(DbDataOps.instance) {
@tanveerprottoy
tanveerprottoy / db.clients.ts
Last active May 3, 2022 10:38
dynamodb-node/nestjs
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";
class DbClients {
private static instance: DbClients;
public dbClient: DynamoDBClient;
public dbDocumentClient: DynamoDBDocumentClient
private constructor() {
console.log('DbClients init');
@tanveerprottoy
tanveerprottoy / file_save.go
Created October 24, 2020 18:27
File upload file save
package app
import (
"io"
"net/http"
"os"
"path/filepath"
)
// FileSave fetches the file and saves to disk