This file contains 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 SomethingWrongException from '../utils/exceptions/base/somethingwrongexception'; | |
import { UserInfoDTO } from '../dtos/user-info-dto'; | |
import CustomException from '../utils/exceptions/customexception'; | |
import DatabaseService from './db-service'; | |
class UserService { | |
private dbService: DatabaseService; | |
constructor() { |
This file contains 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 { NextFunction, Request, Response, Router } from 'express'; | |
import { UserInfoDTO } from '../dtos/user-info-dto'; | |
import UserService from '../services/user-service'; | |
import Controller from '../types/controller'; | |
import HttpResponse from '../utils/response/httpresponse'; | |
import UserResponse from '../utils/response/userresponse'; | |
class UserController implements Controller { | |
public path: string = '/user'; | |
public router: Router = Router(); |
This file contains 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 { Request, Response, NextFunction } from 'express'; | |
import HttpException from '../../utils/exceptions/base/httpexception'; | |
function errorMiddleware(error: HttpException, request: Request, response: Response, next: NextFunction) { | |
const status = error.status || 500; | |
const message = error.message || 'Something went wrong'; | |
const result = error.result || false; | |
console.log(`${request.method} | ${request.path} >> ${message}`); | |
response | |
.status(status) |
This file contains 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 * as BodyParser from 'body-parser'; | |
import * as Express from 'express'; | |
import UserController from './controllers/user-controller'; | |
import ErrorMiddleware from './middlewares/base/errormiddleware'; | |
import Controller from './types/controller'; | |
class App { | |
public app: Express.Application; |
This file contains 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 * as HTTP from 'http'; | |
import App from './app'; | |
import DatabaseService from './services/db-service'; | |
const PORT = 66666; | |
App.set('port', PORT); | |
console.log('Server listening on port : ' + PORT); | |
const server = HTTP.createServer(App); |
This file contains 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 * as Database from 'better-sqlite3'; | |
import { UserInfoDTO } from '../dtos/user-info-dto'; | |
class DatabaseService { | |
private db: Database; | |
constructor() { | |
this.db = new Database('hurray.db', { verbose: console.log }); | |
} |
This file contains 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 * as Winston from 'winston'; | |
import Secret from './secret'; | |
class Logger { | |
private logger: Winston.Logger; | |
public constructor() { | |
this.initializeLogger(); | |
} |
This file contains 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 * as Dotenv from 'dotenv'; | |
import SecretKeys from '../types/secretkeys'; | |
const secretValues: SecretKeys = { | |
ENVIRONMENT: '', | |
PORT: 0, | |
DB_NAME: 'noname.db' | |
}; | |
class Secret { |
This file contains 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
NODE_ENV="prod" | |
PORT="66666" | |
DB_NAME="hurray.db" |
This file contains 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 connection = indexedDB.open('gautam', 1); | |
const startIndex = 1; | |
const stopIndex = 5; | |
connection.onsuccess = (e) => { | |
let results = []; | |
let totalCount = 0; | |
let advanced = startIndex === 1; | |
let counter = startIndex; |
NewerOlder